In PowerShell, how can I test if a variable holds a numeric value?

前端 未结 14 2050
轮回少年
轮回少年 2020-12-16 09:15

In PowerShell, how can I test if a variable holds a numeric value?

Currently, I\'m trying to do it like this, but it always seems to return false.

14条回答
  •  有刺的猬
    2020-12-16 09:58

    PS> Add-Type -Assembly Microsoft.VisualBasic
    PS> [Microsoft.VisualBasic.Information]::IsNumeric(1.5)
    True
    

    http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.information.isnumeric.aspx

提交回复
热议问题