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.
An example can be found on the static Parse
methods on numeric types:
int invalid= int.Parse("Hello");
Notice that those methods provide additional parameters to regulate accepted input formats ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.