Parse is the method we use to convert strings of text into numeric values.
int age = int.Parse(ageString);
The above statement uses int.Parse to convert the string in ageString into an integer result which is then stored in the variable age. This works well, but it is not without its limitations. The problem with Parse is that if you give it a string that contains invalid text it doesn’t know what to do with it. At work if I ever get a problem that I can’t deal with I solve the problem by passing it onto my boss. After all, the boss earns the big bucks and is paid to sort things out. Parse solves its problems by throwing an exception for another part of the program to catch. This is the C# equivalent of a note to the boss that says “I don’t know what to do with this. Any ideas?” If nothing catches the exception (in effect the boss is not around to deal with the problem) then the exception will finish the program. The C# runtime system will display the contents of the exception then stop, as it did above.