Hi, I was wondering if there a way to make it so if something other than int or double is input, it gives an error message.
This is what I got so far:
public static void FirstInput()
{Console.WriteLine("F to C");
Console.Write("Enter number : ");
double.TryParse(Console.ReadLine(), out fromF);
}
//and below is the coding that I got from a friend
Is there a way to integrate those two codes?
if (int.tryParse(Console.ReadLine(), out res))
return res;
console.WriteLine("Error, can't convert, try again");
return GetInteger();
Thank you!
VulpesPosted Oct 17, 2014, 3:49 PM
Song LeePosted Oct 18, 2014, 6:01 PM