title: How to format a number in American and European style in C#?
body: <p>I want to be able to format a number (of type double) in American and European style. Depending on user's choice the number 123123123.456 should be formatted as either:</p>
  
  <ul>
  <li>123,123,123.456  // American format</li>
  <li>123.123.123,456  // European format</li>
  </ul>
  
  <p>Another requirement is to be able to set the number of decimals. I believe I could use <code>double.ToString(string format, IFormatProvider provider)</code> and put <code>"F2"</code> as the <code>format</code> but msdn doesn't seem to tell much about <code>IFormatProvider</code> apart for explaining that I could implement it myself.</p>
  
  <pre><code>double x = 123123123.456
  IFormatProvider myFormatProvider = whatToDo ?
  x.ToString("F2", myFormatProvider); // I need 2 decimal digits hence F2
  </code></pre>
  
  <p>Are there any premade number IFormatProvider objects I could use for that purpose? Or maybe there are other solutions and I'm  going wrong way?</p>