Is FormatException in .NET the equivalent of NumberFormatException in Java ?
-
I think ***YES***. Haven't you tried to read/search it on net? – Harry Joy Dec 14 '11 at 09:08
3 Answers
I think yes both are same following are the details given about both Exception
NumberFormatException (java) : -Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.
FormatException (.net) : - FormatException is thrown when the format of an argument in a method invocation does not match the format of the corresponding formal parameter type. For example, if a method specifies a String parameter consisting of two digits with an embedded period, passing a corresponding string argument containing only two digits to that method would cause FormatException to be thrown.
FormatException uses the HRESULT COR_E_FORMAT, which has the value 0x80131537.
refer http://msdn.microsoft.com/en-us/library/system.formatexception.aspx
http://docs.oracle.com/javase/6/docs/api/java/lang/NumberFormatException.html

- 450,073
- 74
- 686
- 939

- 29,730
- 18
- 72
- 91
Yes. Methods like Double.Parse
throw a FormatException if the string to be converted does not represent a number in a valid format.

- 27,881
- 12
- 83
- 120
Yes, FormatException
is thrown when you try to parse a number from a string with an invalid format (actually it's limited to numbers).

- 286,951
- 70
- 623
- 758