C# Int32 Parse(String, IFormatProvider)
Description
Int32 Parse(String, IFormatProvider)
converts the
string representation of a number in a specified culture-specific format
to its 32-bit signed integer equivalent.
Syntax
Int32.Parse(String, IFormatProvider)
has the following syntax.
public static int Parse(
string s,
IFormatProvider provider
)
Parameters
Int32.Parse(String, IFormatProvider)
has the following parameters.
s
- A string containing a number to convert.provider
- An object that supplies culture-specific formatting information about s.
Returns
Int32.Parse(String, IFormatProvider)
method returns A 32-bit signed integer equivalent to the number specified in s.
Example
The following code shows how to use Parse(String, IFormatProvider) method to convert the user's input to an Int32 value.
using System;/*ww w. jav a 2 s .c om*/
using System.Globalization;
public class MainClass
{
public static void Main(String[] argv)
{
int number;
number = Int32.Parse("123", CultureInfo.InvariantCulture);
System.Console.WriteLine(number);
}
}
The code above generates the following result.