Exception thrown by the Int parse method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.