[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Formatting numbers

I know that I can format a number to a given set of decimal places but is there anyway to format a number so that it only writes decimal places as needed?  

     For example, if I perform a set of calculations that result in variables (type: decimal) equaling the numbers 9, 123.0034, 5.7 and 0.02.  Is there a format that I can use to give me these exact results?  I do not want 9.0000, 5.7000 and 0.0200 but 123.0034 is fine.
0
NevSoFly
Asked:
NevSoFly
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
have you tried: younumbervar.ToString("#,##0.####")
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now