I'm trying to throw a format exception in the instance someone tries to enter a non-integer character when prompted for their age.
Console.WriteLine("Your age:");
age = Int32.Parse(Console.ReadLine());
I'm unfamiliar with C# language and could use help in writing a try catch block for this instance.
Thanks very much.
Int32.Parse
will throw aFormatException
if a non-numeric string is passed to it - your code looks like it does what you want it to? – Sympatheticcatch
a format exception? – Roanne