Identify if a string is a number

前端 未结 25 3370
無奈伤痛
無奈伤痛 2020-11-22 00:13

If I have these strings:

  1. \"abc\" = false

  2. \"123\" = true

  3. \"ab2\"

25条回答
  •  耶瑟儿~
    2020-11-22 00:17

    You can also use:

    stringTest.All(char.IsDigit);
    

    It will return true for all Numeric Digits (not float) and false if input string is any sort of alphanumeric.

    Please note: stringTest should not be an empty string as this would pass the test of being numeric.

提交回复
热议问题