Possible Duplicate:
How to round and format a decimal correctly?
I have this:
double xValue = 0.0;
double yValue = 0.0;
foreach (var line in someList)
{
xValue = Math.Round(Convert.ToDouble(xDisplacement - xOrigin), 2);
yValue= Math.Round(Convert.ToDouble(yDisplacement + yOrigin), 2);
sw.WriteLine("( {0}, {1} )", xValue, yValue);
}
When it does that math it is suppose to round to 2 decimal places.
HOWEVER,
..When a number is something like 6.397 it will round it to 6.4 and not include the trailing "0".
How can I add the "0" at the end of the number?
If I add this to BEFORE (unless there is a better way to do it?) the foreach loop above...:
string properX = xValue.ToString().Replace(".", "");
string properY = yValue.ToString().Replace(".", "");
How would I go about doing this?