0

In my app i use the following

newTotal.ToString("c", (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone())

to convert a inputted number to the number format of the phone. But is there a easy way to convert it back to a simple number again?

Jason94
  • 12,922
  • 36
  • 102
  • 179
  • See this SO post [http://stackoverflow.com/questions/2753701/convert-any-currency-string-to-double][1] [1]: http://stackoverflow.com/questions/2753701/convert-any-currency-string-to-double – Shawn Kendrot Jun 07 '12 at 18:03

2 Answers2

2

Just use double.parse, like this:

var text = (1234,567).ToString("c");

var number = double.Parse(text, System.Globalization.NumberStyles.Currency, cultureInfo);
Pedro Lamas
  • 7,166
  • 4
  • 26
  • 35
0

You can do this with the Parse family of methods. You don't specify what type newTotal is, but parse is available for all numeric primitive types.

Alex Peck
  • 4,515
  • 1
  • 30
  • 37