If you would like to check if mobile phone number is valid (10 digits), try this:
string[] mobilephones = {"9876543214", "987654321", "98765432142", "A876543214", "87C54d2142"};
string pattern = @"^\d{10}$";
var result = mobilephones
.Select(x=>new
{
mobile = x,
IsValid = Regex.IsMatch(x, pattern),
})
.ToList();
foreach(var mb in result)
{
Console.WriteLine("{0} - {1} valid mobile number", mb.mobile, mb.IsValid ? "is" : "is NOT");
}
Result:
9876543214 - is valid mobile number
987654321 - is NOT valid mobile number
98765432142 - is NOT valid mobile number
A876543214 - is NOT valid mobile number
87C54d2142 - is NOT valid mobile number
For further details, please see:
Regex.IsMatch Method[
^]