Well, i've been having a problem with the code of a memory game. It is like a simon says but with numbers in C#.
The problem comes when, in the code, i use the Console Readkey to let the player make an input. But, the problem comes when i convert to int a number... It takes it like i had put a value that mismatched the type of data. Why does that happen=
public void playersTurn() {
for (int i = 0; i < 6; i++) {
if (!(failure)){
playerInput = Console.ReadKey().Key.ToString(); // if i put, for example, 5
Console.Write(playerInput); // it throws 5D50 (this was just to see if something weird was happening)
try{
playerNumber = Convert.ToInt32(playerInput);
}
catch(FormatException e){
Console.Clear();
Console.WriteLine("Solo numeros, chico"); // there is always an exception
}
Console.Write(playerNumber + " ");
if (playerNumber != thoseNumbers[i]) {
Console.WriteLine(" ");
Console.WriteLine("¡ERROR!");
failure = true;
}
}
thoseNumbers[i] = 0;
}