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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version