News

Statistics

Locations of visitors to this page

Personal

 

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
:)
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati