I have the following code:
string[] stringValues = Console.ReadLine().Split(' ');
a = Int32.Parse(stringValues[0]);
b = char.Parse(stringValues[1]);
c = Int32.Parse(stringValues[2]);
What I want is for the user to type 1 number, a letter and another number, Example:
2B4
I tried to do it this way:
string[] stringValues = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
But it didn't work either.
Is there any way to achieve what I want? I appreciate your comments and responses.
You can try to debug characters that can cause an error, double spaces, spaces at the end, tabs and beginning. in case they type: 2 B 4
string string = "2 B 4"; string = string.Replace(" ", "").Replace(" ", "").Replace("\t", "");
Edit for solution: https://docs.microsoft.com/en-us/dotnet/api/system.string.tochararray?view=netcore-3.1