hey..im creating a simple tic tac toe game in c# but im having a small problem. i want the input to be only be accepted if it is between 0 and 8..otherwise ask the user for input again..but i cant seem to get it..here is what i have
Code:
static int getInput()
{
int input;
Console.WriteLine("Please Make Your Move!");
input = Convert.ToInt32(Console.ReadLine());
if(input < 0 || input > 8)
{
Console.WriteLine("Invalid Input!");
getInput();
}
return input;
}
while(!player1.isEmpty(value=getInput())) // check if spot has already been filled
{
Console.WriteLine("Sorry,Alredy Filled!");
}
player1.makeMove(value);
my code does the check fine..but after that if i return a value between 0 and 8..it crashes ??