2

I don't like asking such a small problem, but I found nothing and have no clue, why it's acting like this...

In one of my WebAPI (.NET Core) projects I have declared the following very simple method.

private static string GetDiffText(decimal diff)
{
    var abs = Math.Abs(diff);
    string diffText;

    var absoluteValue = abs.ToString("C", CultureInfo.InvariantCulture);
    if (diff >= 0)
    {
        diffText = $"+{absoluteValue}";
    }
    else
    {
        diffText = $"-{absoluteValue}";
    }
    return diffText;
}

The results of the ToString()-line should be: $23.59

But it actually looks like this:

Dollar sign not recognised

Whats weird about it: When I use my default culture (which is €), the Euro-sign is correctly. So why does the dollar sign make such problems?

Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
Jannik
  • 2,310
  • 6
  • 32
  • 61

0 Answers0