如何在 PowerShell 中獲取變數資料型別?
變數存在不同的資料型別,例如位元組、Int32、浮點、字串等。要獲取變數型別,我們需要使用 GetType() 方法。
示例
$x = 10 $x.GetType()
輸出
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Int32 System.ValueType
要僅獲取變數資料型別,請使用 Name 屬性。
$x.GetType().Name
Int32
廣告