Tuesday, September 18, 2012

How to format a number to x decimal places in C#?

If you have a decimal, double or int data type number and you want to show the number with a certain decimal places then you can use ToString() method from System namespace.
Have a look at these examples. I hope you will find what you need.