Converts decimal to string using standard format and culture
using System;
using System.Globalization;
class MainClass
{
public static void Main()
{
decimal value = 1234567.89m;
CultureInfo culture = CultureInfo.CreateSpecificCulture("eu-ES");
Console.WriteLine(value.ToString("G", culture));
Console.WriteLine(value.ToString("G", CultureInfo.InvariantCulture));
culture = CultureInfo.CreateSpecificCulture("en-US");
Console.WriteLine(value.ToString("C", culture));
culture = CultureInfo.CreateSpecificCulture("en-GB");
Console.WriteLine(value.ToString("C", culture));
culture = CultureInfo.CreateSpecificCulture("sv-SE");
Console.WriteLine(value.ToString("E04", culture));
culture = CultureInfo.CreateSpecificCulture("fr-FR");
Console.WriteLine(value.ToString("F", culture));
culture = CultureInfo.CreateSpecificCulture("en-CA");
Console.WriteLine(value.ToString("F", culture));
culture = CultureInfo.CreateSpecificCulture("es-ES");
Console.WriteLine(value.ToString("N", culture));
culture = CultureInfo.CreateSpecificCulture("fr-CA");
Console.WriteLine(value.ToString("N", culture));
culture = CultureInfo.InvariantCulture;
Console.WriteLine((value / 10000).ToString("P", culture));
culture = CultureInfo.CreateSpecificCulture("ar-EG");
Console.WriteLine((value / 10000).ToString("P", culture));
}
}
/*
1234567,89
1234567.89
$1,234,567.89
1,234,567.89
1,2346E+006
1234567,89
1234567.89
1.234.567,89
1 234567,89
12,345.68 %
12,345.679 %
*/
Related examples in the same category