5

If I do this:

Console.Write("The sum is {0:c}", 12);

I'm on a Swedish computer so it'll return: The sum is 12,00 kr

But is there a simple way of getting just the currency symbol, without a number? Like this (obviously this doesn't work, but just to show what I'm after):

 Console.Write("The symbol is {c}");

I would like that to output: The symbol is kr

Christoffer
  • 7,470
  • 9
  • 39
  • 55
  • Related question http://stackoverflow.com/questions/2763128/get-the-currency-from-current-culture – user7116 Jul 06 '12 at 13:40
  • Googling "currency symbol .net" gave me: http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencysymbol.aspx – mortb Jul 06 '12 at 13:39

3 Answers3

14

You can use:

System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol;
DaveShaw
  • 52,123
  • 16
  • 112
  • 141
10

This code should return the currency symbol you're looking for.

System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol

You could also use the following instead to get the ISO currency symbol

System.Globalization.RegionInfo.CurrentRegion.ISOCurrencySymbol
Spectre87
  • 2,374
  • 1
  • 24
  • 37
  • Thank you. That ISO option looks better in this specific case. – Christoffer Jul 06 '12 at 13:53
  • Are there any certain standards (or opinions) on if it's better to use RegionInfo or CultureInfo? – Christoffer Jul 06 '12 at 14:02
  • 1
    @Tophe According to [MSDN](http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.currentregion.aspx), `System.Globalization.RegionInfo.CurrentRegion` is based on the culture selected through the regional and language options portion of Control Panel. I think CultureInfo can be changed by your application on the fly. – Spectre87 Jul 06 '12 at 14:15
3

You can get it off of the NumberFormat in the CurrentCulture:

Console.Write(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol)
John Koerner
  • 37,428
  • 8
  • 84
  • 134
  • 1
    That returns a $ for me, and I'm pretty sure I'm in the UK ;). It needs to be `CurrentCulture` not `CurrentUICulture`. – DaveShaw Jul 06 '12 at 13:40