Decimal Places
-
How can i specify how many decimal places is displayed when i parse a double to a string?? Sorry, i'm still a beginner with c#!
-
How can i specify how many decimal places is displayed when i parse a double to a string?? Sorry, i'm still a beginner with c#!
Fairly simple: double d = 2.12165464578784545; string s = d.ToString("#.##"); Tomas Rampas ------------------------------ Systems analyst, MCSD rampas(at)gedas(dot)cz http://www.gedas.com/ ------------------------------
-
Fairly simple: double d = 2.12165464578784545; string s = d.ToString("#.##"); Tomas Rampas ------------------------------ Systems analyst, MCSD rampas(at)gedas(dot)cz http://www.gedas.com/ ------------------------------
If you want to maintain a precision of 2, use "#.00" instead of "#.##" so that 0 will be used when no number exits in that position.
Microsoft MVP, Visual C# My Articles