Today, let's look at the exceptions that are thrown by the parse method.
A. Parse method (String):
First, let's introduce the main role of this parse method, converting the string representation of a number to its 32-bit signed integer equivalent. In C + +, its specific syntax is as follows:
Public
static int Parse (
string^ s
)
Where the parameter is s, and the type is string, which contains the number to convert. The return value is int, the 32-bit signed integer equivalent to the number contained in S.
There are three main exceptions to the Parse method:
1) System.ArgumentNullException:
S is a null reference (Nothing in Visual Basic ).
2) System.FormatException:
S is not in the correct format.
3) System.OverflowException:
s represents a number less than MinValue or greater than MaxValue.
Second, the Parse method (String,iformatprovider)
The function of this method is to convert the string representation of a number in a specified style to its 32-bit signed integer equivalent. The syntax is as follows:
public :
static int Parse (
string^ S,
NumberStyle style
)
Where the parameter isS, it'sType is string,A string containing the number to convert. There is one more parameterstyle,Type is NumberStyles,A bitwise combination of the enumeration values that indicates the style elements that can appear in s. A typical value that is used to specify an Integer. return value Type is int, A 32-bit signed integer that is equivalent to the number specified in S.
The exception for this method is mainly four:
1) System. ArgumentNullException:
s for null reference (in No in Visual Basicthing ).
2 ) systeM.argumentexception:
style is not a NumberStyles value. "> style not a value. or a style is not allowhexspecifier and H Exnumberstyle is not a combination of AllowHexSpecifier and hexnumber values. > a combination of values.
style is not a Combination of allowhexspecifier and hexnumber values. > 3) System.FormatException:
style is not a combination of allowhexspecifier and hexnumber values. " > format does not conform to style .
style is not a Combination of allowhexspecifier and hexnumber values. > 4) System.OverflowException:
s represents a number less than MinValue or greater than MaxValue. Or s contains non-zero decimal digits.
Exception thrown by the Int parse method