"::"做什么以及如何在powershell脚本中使用"::"?

Kin*_*NES 4 variables powershell operators

它是C#中objectName.method或属性的等价物吗?一个示例或2将有助于准确学习如何使用以下语法::

Mat*_*sen 9

来自about_Operators帮助主题:

:: Static member operator
    Calls the static properties operator and methods of a .NET
    Framework class. To find the static properties and methods of an
    object, use the Static parameter of the Get-Member cmdlet.


       [datetime]::now
Run Code Online (Sandbox Code Playgroud)

基本上就是这样.

静态成员运算符在左侧使用类型文字,并允许访问该类型的静态成员(方法和属性等):

# The PowerShell class can only be instantiated through a static method called Create()
$psInstance = [powershell]::Create()
Run Code Online (Sandbox Code Playgroud)

您还可以在包含类型的变量上使用它:

$dt = [datetime]
$UtcTimestamp = $dt::UtcNow
Run Code Online (Sandbox Code Playgroud)