mike

mike

  • NA
  • 25
  • 0

decimal.tostring("c") output?

Jul 10 2010 6:56 PM
Hi,

I have some code which displays in a combobox like this;

 combobox.text = myDecimal.ToString("C");

The MSDN page says this should be the output;

 Console.WriteLine(value.ToString("C"));         // Displays ($16,325.62)
So does anyone have any idea why im seeing "$16, 325.62"  ??   The space is being added after the comma.. which means when i try and parse this string later on back in to a decimal using the following code, it fails;
 decimal.Parse(combobox.Text, NumberStyles.Currency);
If i manually remove the space while stepping in to the code in debug, it works fine.  Otherwise it throws invalid format.  I have also tried NumberStyles.Any as well.  I can manually remove the space but i dont want to have to go about doing that :-(  Any ideas why this is happening?

thanks.


Answers (1)