wows wows - 1 year ago 102
C# Question

c# - How do I round a decimal value to 2 decimal places (for output on a page)

When displaying the value of a decimal currently with

, it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places.

Do I use a variation of
for this?

Answer Source
decimalVar.ToString ("#.##");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download