c# - How do I format to only include decimal if there are any -
what best way format decimal if want decimal displayed if not integer.
eg:
decimal amount = 1000m decimal vat = 12.50m
when formatted want:
amount: 1000 (not 1000.0000) vat: 12.5 (not 12.50)
decimal 1 = 1000m; decimal 2 = 12.5m; console.writeline(one.tostring("0.##")); console.writeline(two.tostring("0.##"));
Comments
Post a Comment