title: Format decimal as currency based on currency code
body: <p>I have a table of charges with the amount, and the currency code (USD, JPY, CAD, EUR etc.), and am looking for the easiest way to properly format the currency. Using my local culture code (USA) and taking my decimal.ToString("c") gets me $0.00 output, but I'd like the correct currency sign and number of decimals based on the code.</p>
  
  <p>Do any libraries exist for this? I can of course write up a switch statement and custom rules for each one, but thought this must have been done before.</p>
  
  <p>Update:</p>
  
  <p>I've modified Jon B's sample code as follows </p>
  
  <pre><code>static IDictionary&lt;string, string&gt; GetCurrencyFormatStrings()
  {
      var result = new Dictionary&lt;string, string&gt;();
  
      foreach (var ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
      {
          try
          {
              var ri = new RegionInfo(ci.Name);
              result[ri.ISOCurrencySymbol] =
                    string.Format("{0}#,#0.{1};({0}#,#0.{1})",
                                  ri.CurrencySymbol,
                                  new string('0', 
                                  i.NumberFormat.CurrencyDecimalDigits));
          }
          catch { }
      }
  
      return result;
  }
  </code></pre>
  
  <p>This allows me to simply go Amount.ToString(Currency["JPY"]), and the format will output the comma separator in my local context, but put the correct currency symbol and decimal places in automatically.</p>
  
  <p>Let me know if anyone has a cleaner way of doing this, or I will mark Jon's answer as correct shortly.</p>