Possible Duplicate:
Round a double to 2 significant figures after decimal point
I need at most N decimals, no more, but I don’t want trailing zeroes. For example, if N = 2 then
15.352
15.355
15.3
15
should become (respectively)
15.35
15.36
15.3
15
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try
Math.Round(value, 2).ToString()The second paramater for round is for you to specify how many decimal places to round to. It will round up by default.