变量存在不同的数据类型,例如Byte,Int32,Float,String等。要获取变量类型,我们需要使用GetType()方法。
$x = 10
$x.GetType()
输出结果
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType
要仅获取变量数据类型,请使用Name属性。
$x.GetType().Name
Int32