Link to home
Start Free TrialLog in
Avatar of michael1174
michael1174Flag for United States of America

asked on

Format number without decimal using c# and asp.net

Experts,

I have the following code:

double dblDeductible = double.Parse(reader["DEDUCTIBLE_SIR"].ToString());
this.txtDeductible.Text = dblDeductible.ToString("C");

and I get the result of $2000.00.  I know if I change ToString from a "C" to a "G", I drop the dollar sign.  I want to know how to drop the decimal (".00") so it becomes just 2000 or $2000.

Thanks for any help...
Avatar of mrichmon
mrichmon

You can use any manual formatting you want (I am not sure a built in one will do so)

For example:
double dblDeductible = double.Parse(reader["DEDUCTIBLE_SIR"].ToString());
this.txtDeductible.Text = dblDeductible.ToString("9999");

Where 9 indicates an optional number and 0 is a required number (i.e. will pad with 0 if a required digit is not present)
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland 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