Alright, nub question. I know. Basic response might be
Convert.ToInt32(string);
But naturally, C# does every natural process to make sure just that doesn't happen.
Here's my code:
while (true)
{
while (true)
{
//ask for time
Console.WriteLine("What is the hour?");
Console.WriteLine();
string s = Console.ReadLine();
//convert input to int
YourTime.nHour = Convert.ToInt32(s);
//check to see if it's legal
if ((YourTime.nHour <= 12) || (YourTime.nHour > 0))
{
break;
}
//etc etc code
}
}
I want to make sure the input is an actual hour. When I run this code, it always labels the if() statement as "true" and breaks, even if I inputted something like -13 or 99.
I'm sure there's a simple replacement for "Convert.ToInt32(s);", but to be honest it seems like I've tried everything. I decided it would be best to follow step-by-step instructions from people who are aware of the code at hand.
[EDIT] - Wrong operator, not the conversion. Thanks to everyone who helped!