Export (0) Print
Expand All

Decimal.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)

The return value is formatted with the general numeric format specifier ("G").

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

NoteNote:

Because the Decimal data type is not supported on the Macintosh OS X operating system, the string representation of a Decimal value may be different from those of the other .NET Framework numeric types that are supported by OS X.

The provider parameter is an IFormatProvider implementation whose IFormatProvider.GetFormat method returns a NumberFormatInfo object. Typically, provider is a NumberFormatInfo object or a CultureInfo object. The provider parameter supplies culture-specific information used in formatting. If provider is null, the thread current culture is used.

To convert a Decimal value to its string representation using a specified culture and a specific format string, call the Decimal.ToString(String, IFormatProvider) method.

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


decimal value = -16325.62m;
// 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.62
//       -16325.62
//       -16325,62


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

ADD
Show:
© 2014 Microsoft