Geeks With Blogs
marocanu2001 technicle blog
I just came upon this issue. I have a textbox that contains a value formatted to currency :

        Decimal val = 567.3;
        CultureInfo ci = new CultureInfo("en-GB");
        string currency = val.ToString("C", ci);

this produces string : 567.3 "
       
And in another place I needed the number from currency, so I had to convert the formatted currency back to decimal.
And here's the tip:

  string currency = 567.3 ";
  CultureInfo ci = new CultureInfo("en-GB");

  decimal val =  Decimal.Parse(currency , NumberStyles.Currency, ci.NumberFormat);

and val is number 567.3 ... no error .. tadaaa
:) Posted on Tuesday, February 5, 2008 10:44 PM | Back to top


Comments on this post: Convert Currency string back to decimal

# re: Convert Currency string back to decimal
Requesting Gravatar...
Thanks for posting this :)
Left by Nikkie on Oct 19, 2009 4:47 PM

# re: Convert Currency string back to decimal
Requesting Gravatar...
Thanks a lot for this nice post. Keep it up.
Left by Ven on Dec 02, 2009 1:07 PM

# re: Convert Currency string back to decimal
Requesting Gravatar...
Its save me lot of time.
Thanks.
Its very simple and impressive.
Left by raakesh tomar on Jul 14, 2011 5:53 PM

# re: Convert Currency string back to decimal
Requesting Gravatar...
nice thanx
Left by Nilesh on Sep 14, 2015 12:33 AM

Your comment:
 (will show your gravatar)


Copyright © marocanu2001 | Powered by: GeeksWithBlogs.net