I have a textbox on GUI which takes an "Mobile Number" as input. I want to validate it to find out if it has some characters, which would mean the number is invalid
So, a number 9876543210 is valid while a number 98765df013 is invalid
I made a array of all characters (which are not allowed by me)
string[] alphabeticChars = new string[] {
"a", "b", "c", "d", "e", "f", "g",
"h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z"
};
and then I wrote a validation function
public bool HasCharacters(string text)
{
foreach(string character in this.alphabeticChars)
if(text.Contains(character.ToLower()) || text.Contains(character.ToUpper()))
return true;
return false;
}
As you can see, I need to call Contains twice, one for "Lower Case" and another time for "Upper Case". I checked and couldn't find ContainsIgnoreCase or something.
What is the best way to to such a thing ? (Don't mention regular expressions, as I don't want to use them)