Posts Tagged ‘.NET’

Display decimals for a number

Friday, May 9th, 2008

The .ToString method has some wonderful features. If you want to display only 2 decimals for a number, you just have to display the format, like this: yourNumber.ToString(”N2″).

I found this solution on http://www.geekpedia.com/Question10_How-can-I-format-a-number-to-x-decimal-places.html. You can find there more formatting methods, in case you have some strict preferences.