check if a string contains only numbers and 10 numbers 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: if string contains number c#
"abc3def".Any(c => char.IsDigit(c));
// Or to make it shorter:
"abc3def".Any(char.IsDigit);