2016-07-20 1 views

答えて

5

この構文を使用する方法を正確に学ぶために参考になるトピックを助ける:

:: 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 

基本的にはこれだけです。

静的メンバオペレータが左側のリテラル型をとり、(同様のメソッドおよびプロパティ)その型の静的メンバへのアクセスを可能にする:

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

あなたはまた、Aを含む変数にそれを使用することができタイプ:

$dt = [datetime] 
$UtcTimestamp = $dt::UtcNow 
+0

ありがとうございます:: ::基本的にコマンドを参照する方法です。 Object.getObjectName()と同様。 –

+0

@KingofNES *のみ* ** static **メソッド - インスタンスメソッドではありません。 –

+0

'::'を '[Type]' value: '' $ now = Get-Dateだけでなく、任意の値に適用できます。 $ now :: UtcNow'。 – PetSerAl

関連する問題