Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get system currency symbol to a string

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

like image 534
Christoffer Avatar asked Jul 06 '12 13:07

Christoffer


2 Answers

You can use:

System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol;
like image 198
DaveShaw Avatar answered Sep 28 '22 09:09

DaveShaw


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
like image 32
Spectre87 Avatar answered Sep 28 '22 11:09

Spectre87