double myDouble1 = 0.32;
double myDouble2 = 321.5235;
var currentCulture = CultureInfo.InvariantCulture.Clone() as CultureInfo;
var numberFormat = currentCulture.NumberFormat;
numberFormat.NumberDecimalDigits = 2;
Console.WriteLine(myDouble1.ToString("F", numberFormat));
Console.WriteLine(myDouble2.ToString("F", numberFormat));
double myDouble2 = 321.5235;
var currentCulture = CultureInfo.InvariantCulture.Clone() as CultureInfo;
var numberFormat = currentCulture.NumberFormat;
numberFormat.NumberDecimalDigits = 2;
Console.WriteLine(myDouble1.ToString("F", numberFormat));
Console.WriteLine(myDouble2.ToString("F", numberFormat));
No comments:
Post a Comment