Newbie question. “Input String was not in a correct format” exception.

Hello. I started learning programming and c# a while ago. I was making an exercise about a console application that asks from the user 3 ints and then shows up the biggest.

I made it work, but in case the user doesn't type an int and presses ENTER, the app crashes, and I get the exception window with the message: "Input String was not in a correct format".

I was wondering if there is a way to tell the program that in case the user inputs a non integer value like in this particular case, instead of a crash I could have it output a message like "Please type an integer!" on the console window, and have the program keep running.

by Alithinos via /r/csharp

Leave a Reply