How to get specific culture currency pattern

A CultureInfo contains a NumberFormatInfo and this class describes (among other things) how to format currency for that particular culture.

In particular you can use CurrencyPositivePattern and CurrencyNegativePattern to determine if the currency symbol is placed before or after the amount and of course CurrencySymbol to get the correct currency symbol. All this information is used by .NET when the C format specifier is used.

You can read more about the NumberFormatInfo class on MSDN.

The code below demonstrates some of the steps required to format currency properly. It only uses CurrencySymbol, CurrencyPositivePattern and CurrencyDecimalDigits and thus is incomplete:

var amount = 123.45M;
var cultureInfo = CultureInfo.GetCultureInfo("da-DK");

var numberFormat = cultureInfo.NumberFormat;
String formattedAmount = null;
if (amount >= Decimal.Zero) {
  String pattern = null;
  switch (numberFormat.CurrencyPositivePattern) {
    case 0:
      pattern = "{0}{1:N" + numberFormat.CurrencyDecimalDigits + "}";
      break;
    case 1:
      pattern = "{1:N" + numberFormat.CurrencyDecimalDigits + "}{0}";
      break;
    case 2:
      pattern = "{0} {1:N" + numberFormat.CurrencyDecimalDigits + "}";
      break;
    case 3:
      pattern = "{1:N" + numberFormat.CurrencyDecimalDigits + "} {0}";
      break;
  }
  formattedAmount = String.Format(cultureInfo, pattern, numberFormat.CurrencySymbol, amount);
}
else {
  // ...
}

Console.WriteLine(formattedAmount);

Of course you could simply use:

var amount = 123.45M;
var cultureInfo = CultureInfo.GetCultureInfo("da-DK");
var formattedAmount = String.Format(cultureInfo, "{0:C}", amount);
Console.WriteLine(formattedAmount);

You need to format your currency/double using:

money.ToString("C", culture);

The hard part is actually getting the right culture based on the ISO code. I do not know how you keep track of the culture you need. Keep in mind this is simply the formatting of your money, not conversion to different currencies/cultures!

More detail:

ISOCurrencySymbol is a part of RegionInfo, which you can create based on CultureInfo, which you can retrieve from your current thread's culture settings. You should create a singleton which implements a dictionary to convert from ISOCurrencyCode to CultureInfo.


I think what you're asking is how to change the currency symbol but keep the culture-specific formatting. You can do this by getting a copy of the current NumberFormatInfo and modifying the CurrencySymbol property:

Thread.CurrentThread.CurrentCulture = new CultureInfo("de");
// pretend we are german

var nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
nfi.CurrencySymbol = "$$$";
Console.WriteLine(string.Format(nfi,"{0:c}",345.10));

This will output:

345,10 $$$

Without changing the CurrentCulture it outputs (for me):

$$$345.10

Quick and dirty approach that works for all number formats is:

var culture = CultureInfo.GetCultureInfo("el-GR");
var numberFormat = (NumberFormatInfo)culture.NumberFormat.Clone();
numberFormat.CurrencySymbol = "€";  // Force the currency symbol regardless of culture
var specifier = "C";                // Or any other format specifier
var positivePattern = 1110.ToString(specifier, numberFormat).Replace('1', '#');
var negativePattern = (-1110).ToString(specifier, numberFormat).Replace('1', '#');
var pattern = positivePattern + ";" + negativePattern;

In this case, pattern equals "#.##0,00 €;-#.##0,00 €". This avoids a lot of headaches trying to figure out all of the permutations. I appreciate the question being asked, as it helped and forced me to find an easier answer.