If I have these strings:
(如果我有这些字符串:)
"abc" = false
"abc"
false
("abc" = false)
"123" = true
"123"
true
("123" = true)
"ab2" = false
"ab2"
("ab2" = false)
Is there a command, like IsNumeric() or something else, that can identify if a string is a valid number?
IsNumeric()
(是否存在诸如IsNumeric()类的命令,可以识别字符串是否为有效数字?)
int n; bool isNumeric = int.TryParse("123", out n);
Update As of C# 7:
(从C#7开始更新 :)
var isNumeric = int.TryParse("123", out int n);
The var s can be replaced by their respective types!
(var可以用它们各自的类型替换!)
2.1m questions
2.1m answers
60 comments
56.9k users