Int32.Parse(String) Method is used to convert the string representation of a number to its 32-bit signed integer equivalent.
public static int Parse (string str);
Here, str is a string that contains a number to convert. The format of str will be [optional white space][optional sign]digits[optional white space].
Return Value: It is a 32-bit signed integer equivalent to the number contained in str.
- ArgumentNullException: If str is null.
- FormatException: If str is not in the correct format.
- OverflowException: If str represents a number less than MinValue or greater than MaxValue.
Below programs illustrate the use of above-discussed method:
'2147483647' parsed as 2147483647 Can't Parsed '214,7483,647' '-2147483' parsed as -2147483 ' 2183647 ' parsed as 2183647
Example 2: For ArgumentNullException
Exception Thrown: System.ArgumentNullException
- MathF.Sin() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Exp() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- Type.FindMembers() Method in C# with Examples
- Int32.Equals Method in C# with Examples
- Int64.Equals Method in C# with Examples
- Int64.GetHashCode Method in C# with Examples
- Int16.Equals Method in C# with Examples
- Int32.CompareTo Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.