FormatException
Quite often, string objects are used to accept inputs that have a certain structured form, like a number’s string representation or a URI. In such a case, the String type does not support enough validation of input by itself, and additional checking will be carried out by the consumer of the string object. For example, a number consists of digits, possibly with a decimal separator character, a sign character, or an exponent used in scientific notation. If this form is not respected for the string-based input, a FormatException is raised.
The static Parse methods on numeric types provide an example:
int invalid= int.Parse("Hello");
Notice that those methods provide additional parameters to regulate accepted input formats (for example, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access