What is the .NET equivalent for Java NumberFormatException?

Is FormatException in .NET the equivalent of NumberFormatException in Java?

+7
source share
3 answers

I think both of them are as follows: exception details

NumberFormatException (java): -It is shown to indicate that the application tried to convert the string to one of the number types, but that the string does not have the appropriate format.

FormatException (.net): - FormatException is thrown when the format of the argument in the method call does not match the format of the corresponding formal parameter type. For example, if a method sets a String parameter that consists of two digits with a built-in period, passing the corresponding string argument containing only two digits of this method will throw an Exception formatting.

FormatException uses HRESULT COR_E_FORMAT, which has the value 0x80131537.

contact http://msdn.microsoft.com/en-us/library/system.formatexception.aspx

http://docs.oracle.com/javase/6/docs/api/java/lang/NumberFormatException.html

+6
source

Yes. Methods such as Double.Parse throw a FormatException if the string to be converted does not represent a number in a valid format.

+2
source

Yes, a FormatException is FormatException when trying to FormatException number from a string with an invalid format (this is actually limited to numbers).

0
source

All Articles