3 Digit currency code to currency symbol

前端 未结 9 1198
逝去的感伤
逝去的感伤 2020-12-04 10:19

In C# is it possible to get a currency symbol, like \'£\', from the 3 character currency code, in this case \'GBP\'?

Is this possible either in SQL Server or in C#?<

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 11:00

    Try this code. Enter 'USD' as CurrencyCode and all other.

    public string getCurrencySymbol(string CurrencyCode)    
    {
            string symbol = string.Empty;
            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            IList Result = new ArrayList();
            foreach (CultureInfo ci in cultures)
            {
                RegionInfo ri = new RegionInfo(ci.LCID);
                if (ri.ISOCurrencySymbol == CurrencyCode)
                {
                    symbol = ri.CurrencySymbol;
                    return symbol;
                }
            }
            return symbol;
    
        }
    

提交回复
热议问题