Decimal::ToString Method (String, IFormatProvider)

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

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

No code example is currently available or this language may not be supported.

Parameters

format
Type: System::String
A standard or custom numeric format string (see Remarks).
provider
Type: System::IFormatProvider
An IFormatProvider implementation that supplies culture-specific formatting information.

Return Value

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

Implements

IFormattable::ToString(String, IFormatProvider)

ExceptionCondition
FormatException

format is invalid.

The format parameter can be any valid standard numeric format specifier except for D, R, and X, as well as any combination of custom numeric format specifiers. If format is nullptr or an empty string, the return value for this instance 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 or CultureInfo object. The provider parameter supplies culture-specific information used in formatting. If provider is nullptr, the thread current culture is used.

The following example displays a Decimal value using each of the supported standard numeric format specifiers for several different cultures.

No code example is currently available or this language may not be supported.

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: