I'm having issues with currency formatting in C#. I'm using framework 2.0.
When I use this code:
CultureInfo culture = new CultureInfo("fr-FR", false);
NumberFormatInfo numberFormatInfo = (NumberFormatInfo)culture.NumberFormat.Clone();
numberFormatInfo.CurrencySymbol = "CHF";
price.Value.ToString("C", numberFormatInfo)
seems to give me a string with a white space between amount and currency. That's horrible! I absolutely need a no-break space!
What is going on? Am I missing a format property or is it the C# standard?
Thanks for your help!
So basically you want price.Value.ToString("C", numberFormatInfo).Replace(' ', '\u00A0');? At least that should be the code for non breaking space. – Corak
Exactly the same as above commentor, but using the asci-values instead; > price.Value.ToString("C", numberFormatInfo).Replace((char) 32, (char) 160); (160 is a lot > easier to remember, atleast for me :)) – flindeberg
price.Value.ToString("C", numberFormatInfo).Replace(' ', '\u00A0');
? At least that should be the code for non breaking space. – Nuristanprice.Value.ToString("C", numberFormatInfo).Replace((char) 32, (char) 160);
(160 is a lot easier to remember, atleast for me :)) – Shumpert(char) 160
:) – Shumpert