how to check string contains only numbers in c# code example
Example 1: c# check if string is only letters and numbers
if (textVar.All(c => Char.IsLetterOrDigit(c))) {
// String contains only letters & numbers
}
Example 2: c# check if string is all numbers
if (str.All(char.IsDigit)) {
// String only contains numbers
}