I have an application where I want to format a currency using the country's native currency formatting. Problem is, certain countries use multiple currencies, but .NET only assigns one currency per country. For example, Romania uses EUR and RON. When I get the currency info from .NET:
var cultureInfo = new CultureInfo("ro-RO");
Console.WriteLine("cultureInfo.NumberFormat.CurrencySymbol);
The output is leu
, which is the RON currency type.
How would I get EUR for this case in .NET? I have the 3-letter ISO currency code (EUR) and the country language (ro-RO) but I don't know how to use this info to get a correctly-formatted euros currency string.
You can replace currency symbol with a custom one (leu to euro in this case)
NumberFormatInfo LocalFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
LocalFormat.CurrencySymbol = "€";
decimal money = 100;
Console.WriteLine(money.ToString("c", LocalFormat));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With