How would I get the number after a decimal point in VB.NET

后端 未结 8 1913
猫巷女王i
猫巷女王i 2021-01-27 12:10

Can anyone give me an easy way to find out the numbers after the decimal point of the double?
All i need to do is to find out if the number ends in 0 like 1.0 or 10.0 or 32

8条回答
  •  孤城傲影
    2021-01-27 12:59

    If your input is a string, and you want to identify strings that have decimals, but where those decimal places are all zero, then you could use a regular expression:

    var regex = new Regex("^-?\\d+\\.0+$");
    if (new Regex.IsMatch(input))
    {
        // it's in the format you want
    }
    

提交回复
热议问题