Get Currency Name - CSharp System.Globalization

CSharp examples for System.Globalization:Country

Description

Get Currency Name

Demo Code


using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Globalization;
using System.ComponentModel;
using System.Collections.Generic;
using System;/*  w w  w .j a v a 2 s .c  om*/

public class Main{
        public static string GetCurrencyName(this string isoCurrencySymbol)
		{
			return CultureInfo
				.GetCultures(CultureTypes.AllCultures)
				.Where(c => !c.IsNeutralCulture && c.LCID != 127)
				.Select(culture =>
				{
					try
					{
						return new RegionInfo(culture.LCID);
					}
					catch
					{
						return null;
					}
				})
				.Where(ri => ri != null && ri.ISOCurrencySymbol == isoCurrencySymbol)
				.Select(ri => ri.CurrencyNativeName)
				.FirstOrDefault() ?? isoCurrencySymbol;
		}
}

Related Tutorials