简体   繁体   中英

How can I get the hundredth currency symbol?

I want to get the hundredth currency symbol for any currency code For example cents symbol, USD hundredth symbol => ¢ I want to do that in C# or JavaScript . Is there any map or build-in generic functionality to do that in C# or JavaScript? I already can do that with the currency symbol but not the hundredth currency symbol. I want to get the symbol itself using the currency code.

Update: My question is how not to do it manually, you can imagine how long it will take to collect all currency hundredth symbol and create the dictionary. I prefer if there is any library or map out there to use quickly.

Reference your last comment:

Define a dictionary

First, define a class like this

public class CurrencySymbols
{
    public string cur { get; set; }
    public string hundredth { get; set; }
}

Then use it to define dictionary like this:

        var currencySymbols = new Dictionary<string, CurrencySymbols>();
        currencySymbols.Add("USA", new CurrencySymbols { cur = "$", hundredth = "¢" });
        currencySymbols.Add("EU", new CurrencySymbols { cur = "€", hundredth = "¢" });

        foreach (var currency in currencySymbols)
        {
            Console.WriteLine(currency.Key, currency.Value.cur, currency.Value.hundredth);
        }

How to access the value:

    var symbolNeeded = currencySymbols["EU"].cur; //For Euro

    var symbolNeeded2 = currencySymbols["EU"].hundredth; //For hundredth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM