2 Replies - 291 Views - Last Post: 28 September 2012 - 06:25 PM Rate Topic: -----

#1 Varlisk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 20-September 12

Need output to be 2 decimal positions.

Posted 28 September 2012 - 06:11 PM

For class, I made a program that lists various items along with a cost. Next to the items are text boxes for quantity of the item. When I click a button it provides a total price.

For the most part, my program works, but I need it to display 1.30 instead of 1.305847.

If I need to post my code I will.
Is This A Good Question/Topic? 0
  • +

Replies To: Need output to be 2 decimal positions.

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1606
  • View blog
  • Posts: 5,163
  • Joined: 25-September 09

Re: Need output to be 2 decimal positions.

Posted 28 September 2012 - 06:22 PM

The .ToString method can take parameters
You can for example take an Double of 1.305847 and override it with .ToString("N2") you will get 1.31 in the result.

This post has been edited by CharlieMay: 28 September 2012 - 06:22 PM

Was This Post Helpful? 0
  • +
  • -

#3 Varlisk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 20-September 12

Re: Need output to be 2 decimal positions.

Posted 28 September 2012 - 06:25 PM

View PostCharlieMay, on 28 September 2012 - 06:22 PM, said:

The .ToString method can take parameters
You can for example take an Double of 1.305847 and override it with .ToString("N2") you will get 1.31 in the result.


Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1