Link to home
Start Free TrialLog in
Avatar of rpkhare
rpkhareFlag for India

asked on

Retrieving two decimal places

I want to retrieve value upto decimal places. How to modify this line:

GrossTotal = Convert.ToDecimal(txtGrossAmount.Text);

I want that GrossTotal has value like this:

123.45
2455.78
ASKER CERTIFIED SOLUTION
Avatar of rambovn
rambovn
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rpkhare

ASKER

Which one is more fast and adds no overhead?
I use the ToString version personally.  Sometimes when using Math.Round and adding it to the .Text property of a control, it will not add your trailing zeros.
If you use GrossTotal  for calculating then using Math.Round.
If you use GrossTotal  for printing then using imateyelectronics' version.

See http://msdn.microsoft.com/en-us/library/364x0z75(VS.80).aspx for more information on Decimal.