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)

abstract ToString : 
        provider:IFormatProvider -> string
override ToString : 
        provider:IFormatProvider -> string

Parameters

provider
Type: System.IFormatProvider

An object that supplies culture-specific formatting information.

Return Value

Type: System.String

The string representation of the value of this instance as specified by provider.

The ToString(IFormatProvider) method formats a Decimal value in the default ("G", or general) format of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the ToString method, as follows:

To use format

For culture

Use the overload

Default ("G") format

Default (current) culture

ToString()

A specific format

Default (current) culture

ToString(String)

A specific format

A specific culture

ToString(String, IFormatProvider)

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

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.

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

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: