Trimming a number to 2 decimal places + remove trailing zeros

I'd like to display a numer in the format XXX.XX, but also trim off any trailing zeros that exist in the remaining 2 decimal places.

Can anyone tell me the best way to display this number?  I'm going to use the code in a function, that will accept a double value as the input.

i.e.
33.333333  --->  33.33
25.50         --->  25.5
50             --->   50
LVL 25
RouchieAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
Hi Rouchie,

MyNumberString = MyNumericValue.ToString("#.##")

Tim Cottee
0
 
RouchieAuthor Commented:
I knew it would be really simple but couldn't find any information online to help me solve it!

Thanks Tim.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.