Best implementation for an isNumber(string) method

前端 未结 19 2604
感动是毒
感动是毒 2020-12-15 20:04

In my limited experience, I\'ve been on several projects that have had some sort of string utility class with methods to determine if a given string is a number. The idea h

19条回答
  •  星月不相逢
    2020-12-15 20:20

    Personally I would do this if you really want to simplify it.

    public boolean isInteger(string myValue)
    {
        int myIntValue;
        return int.TryParse(myValue, myIntValue)
    }
    

提交回复
热议问题