I want to round a double value to the nearest $100,000 (i.e. $3,456,789 = $3.500,000)
However this needs to be done as a string because it is a label for an open source Chart drawing tool that takes a string to create the labels.
Any suggestions?
Loading
VulpesPosted Mar 1, 2012, 11:31 AM
string s = "$3,456,789";
string t = s.Substring(1).Replace(",", "");
double d = double.Parse(t);
d = Math.Round(d/100000) * 100000;
t = d.ToString("C0"); // $3,500,000
ThomasPosted Mar 1, 2012, 12:00 PM
Thanks for the quick answer.