2
cjbatz
6y

Can anybody explain why in C# when using string.Format("{0:C}", myNumber);
results in a string with special characters used for spacing instead of the normal space character.

This caused a issues in the PDF I was generating and I'm wondering why the special characters.

Comments
  • 0
    This is how I fixed it;

    string cleanedText = new string(formatedMoney.Select(c => (char.IsSeparator(c) || char.IsWhiteSpace(c)) ? ' ' : c).ToArray());
  • 0
    I dont know much about the format language in C# but I'm guessing it has something to do with the 'C' in your format string. In Python stuff after the delimiter (':' here) make it format stuff in special ways; have you tried using plain "{}"?
  • 0
    Check the culture info on your machine
  • 0
    @Vake93 & @tokumei
    Yea, I was formatting to my local currency, and that works perfectly for the most part.
    My problem was that the resulting formatted string was using a special charter for spacing instead of a normal space. This caused issues when I output the data in a PDF. I'm just trying to understand why they would use a special character.
Add Comment