Answers for "c# how to check if string contains numbers"

C#
3

if string contains number c#

"abc3def".Any(c => char.IsDigit(c));

// Or to make it shorter:
"abc3def".Any(char.IsDigit);
Posted by: Guest on August-23-2020
2

c# how do you check if a string contains only digits

if (str.All(char.IsDigit)) {
  Console.WriteLine("This string only contains numbers");
}
Posted by: Guest on November-08-2020

Code answers related to "c# how to check if string contains numbers"

C# Answers by Framework

Browse Popular Code Answers by Language