check if string is a number unity code example
Example 1: c# how to check string is number
string s1 = "123";
string s2 = "abc";
bool isNumber = int.TryParse(s1, out int n); // returns true
isNumber = int.TryParse(s2, out int n); // returns false
Example 2: flutter check if string is number
bool isNumeric(String s) {
if (s == null) {
return false;
}
return double.tryParse(s) != null;
}