C# Decimal ToString(IFormatProvider)
Description
Decimal ToString(IFormatProvider)
converts the numeric
value of this instance to its equivalent string representation using the
specified culture-specific format information.
Syntax
Decimal.ToString(IFormatProvider)
has the following syntax.
public string ToString(
IFormatProvider provider
)
Parameters
Decimal.ToString(IFormatProvider)
has the following parameters.
provider
- An object that supplies culture-specific formatting information.
Returns
Decimal.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 a Decimal value using CultureInfo objects that represent several different cultures.
using System;/*w w w .j a va 2s. c om*/
using System.Globalization;
public class MainClass
{
public static void Main(String[] argv)
{
decimal value = -16325.62m;
// Display value using the invariant culture.
System.Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
// Display value using the en-GB culture.
System.Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
// Display value using the de-DE culture.
System.Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("de-DE")));
}
}
The code above generates the following result.