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