I am trying to use an if statement and a int.tryparse to try and create a loop that keeps running until a proper integer is given. A friend of mine said it could be done using an the pieces I mentioned above. Yet I have my doubts, was wondering if anyone could either verify this works or help me figure it out.
so far I have
if (!int.TryParse(temp, out move))
{
Console.WriteLine("Bad integer")
}
Looking at this I don't see how it would loop, I was thinking a while loop might work better but am at a loss as to how I would set one up.
Thanks in advance,
Jeff
string temp = null; do{ if(temp != null)Console.WriteLine("Bad integer"); temp = Console.Readkey(); }while(int.TryParse(temp, out move);