I am writing a program in C#, and I want to catch exceptions caused by converting "" (null) to int. What is the exception’s name?
EDIT:
I’m not sure I can show the full code… But I’m sure you don’t need the full code, so:
int num1 = Int32.Parse(number1.Text);
int num2 = Int32.Parse(number2.Text);
If you can avoid it, do not code by exception!
The exception name you are looking for is called a
FormatException.However, it would be smarter to first do a
TryParseon the object you are attempting to parse, e.g.