What\'s the easiest way to parse a string and extract a number and a letter? I have string that can be in the following format (number|letter or letter|number), i.e \"10A\",
The easiest and fastest is to use simple string operations. Use the IsDigit method to check where the letter is, and parse the rest of the string to a number:
char letter = str[0];
int index = 1;
if (Char.IsDigit(letter)) {
letter = str[str.Length - 1];
index = 0;
}
int number = int.Parse(str.Substring(index, str.Length - 1));