Link to home
Start Free TrialLog in
Avatar of trevorhartman
trevorhartmanFlag for United States of America

asked on

parsing dollar values - URGENT

Hi,

I have a string = to a dollar value. eg:

string dollars = "$15.45";

how do I parse it into a decimal?

i want:

decimal decPrice == 15.45;

but i want to do it by parsing the string into a decimal.. do I use an Iformatprovider or something? please give an example, i don't know how to use iformatprovider

thanks

-Trevor
SOLUTION
Avatar of tusharashah
tusharashah

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 trevorhartman

ASKER

thanks for the reply, i'll put that in place for now... but i'm curious to see how to do it with an IFormatProvider because I want to be able to use that for other things in the future.  How do I tell decimal.Parse that my string is in a currency format so it knows how to parse?

-Trevor
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
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
thx for the suggestions guys, but i'm still wondering on the IFormatProvider thing...
ASKER CERTIFIED 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
Thanks tushar.

this did it for me:

double dollars = double.Parse("$13.40", NumberStyles.Currency);

-Trevor
Avatar of tusharashah
tusharashah

Nice to have you going!

Thanks for A

-tushar