Forcing a number to 2 decimal places in C#

Hey guys

On my website i have numbers that get calculated according to what the use types in. I need the number 2 be forced to 2 decimal places.

At the moment im using Math.Round(decOne,2);

that changes this: 65.231 into 65.23
but if the user types in 65 it stays 65 and doesn’t give me 65.00. Is there anyway to make the number to force 2 decimal places?

I hope i explained this correctly.

Thanks

.ToString (“0.00”)

Hey puco

Thanks a lot for the quick reply. It works great.

Thanks again

You mean to show it as decimal in a textbox or label right? I’m pretty sure that in your single or double variable, it will be as 65.00, but in the textbox/label, you can format it using toString.

Hopefully this link helps:

whoops… got beat to posting the reply :slight_smile: