C# Int32 ToString(IFormatProvider)

Description

Int32 ToString(IFormatProvider) converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

Syntax

Int32.ToString(IFormatProvider) has the following syntax.


public string ToString(
  IFormatProvider provider
)

Parameters

Int32.ToString(IFormatProvider) has the following parameters.

  • provider - An object that supplies culture-specific formatting information.

Returns

Int32.ToString(IFormatProvider) method returns The string representation of the value of this instance as specified by provider.

Example

The following example displays the string representation of an Int32 value using CultureInfo objects that represent several different cultures.


using System;/* w w  w.j  a v  a2 s . c o m*/
using System.Globalization;
public class MainClass{
  public static void Main(String[] argv){  
    int value = -123456;
    // Display value using the invariant culture.
    Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
    // Display value using the en-GB culture.
    Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
    // Display value using the de-DE culture.
    Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("de-DE")));

  }
}

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