Export (0) Print
Expand All

Int32.ToString Method (IFormatProvider)

Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

[SecuritySafeCriticalAttribute]
public string ToString(
	IFormatProvider provider
)

Parameters

provider
Type: System.IFormatProvider
An IFormatProvider that supplies culture-specific formatting information.

Return Value

Type: System.String
The string representation of the value of this instance as specified by provider.

Implements

IConvertible.ToString(IFormatProvider)

This instance is formatted with the general numeric format specifier ("G").

The provider parameter is an object that implements the IFormatProvider interface. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific information about the format of the string that is returned by this method. The object that implements IFormatProvider can be any of the following:

If provider is null or a NumberFormatInfo object cannot be obtained from provider, the return value is formatted using the NumberFormatInfo object for the thread current culture. For information about the thread current culture, see Thread.CurrentCulture.

The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

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


int value = -16325;
// Display value using the invariant culture.
outputBlock.Text += value.ToString(CultureInfo.InvariantCulture) + "\n";
// Display value using the en-GB culture.
outputBlock.Text += value.ToString(new CultureInfo("en-GB")) + "\n";
// Display value using the de-DE culture.
outputBlock.Text += value.ToString(new CultureInfo("de-DE")) + "\n";
// This example displays the following output:
//       -16325
//       -16325
//       -16325


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

Show:
© 2014 Microsoft