I want to format a number in C#.Net and I need a builtin function that performs this thing.But I couldn't find such a function in C#.Net.For example the builtin function that convet the number 1500.5236 to 1500.52.
Formatting a number in C#.Net?
If you actually want to round the number to, say 2 decimal places, then use:
Math.Round(number, 2)
If you just want to display the number to 2 decimal places then use:
number.ToString("f02")
Also take a look at the documentation for Double.ToString()
http://msdn2.microsoft.com/en-us/library...
And Numeric Format Strings
http://msdn2.microsoft.com/en-us/library...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment