c# check number in string code example
Example 1: c# check if string is all numbers
if (str.All(char.IsDigit)) {
// String only contains numbers
}
Example 2: c# see if string is int
bool result = int.TryParse("123", out var n);
if (str.All(char.IsDigit)) {
// String only contains numbers
}
bool result = int.TryParse("123", out var n);