title: Write double to text file with dot separator
body: <p>I need to write several doubles in text file with dot separator. I know, that this code is the solution:</p>
  
  <pre><code>StreamWriter f = new StreamWriter(file, Encoding.ASCII, 128, false);
  double a = 1.057887;
  f.Write(a.ToString("G5", CultureInfo.InvariantCulture));
  </code></pre>
  
  <p>but I have too many numbers to write, so I tried method from <a href="https://stackoverflow.com/questions/1421520/formatting-doubles-for-output-in-c-sharp">this answer</a>:</p>
  
  <pre><code>f.Write("{0:0.#####} {0:0.#####} {0:0.#####} {0:0.#####} {0:0.#####}", a, a, a, a, a));
  </code></pre>
  
  <p>and also tried to <a href="https://stackoverflow.com/questions/3135569/how-to-change-symbol-for-decimal-point-in-double-tostring">change the culture globally</a>:</p>
  
  <pre><code>System.Threading.Thread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
  </code></pre>
  
  <p>But the first one '{0:0.#####}' resulted in comma separator (1,05789), and the second one 'Thread' in CS0120: An object reference is required for the non-static field, method, or property.</p>
  
  <p>And another problem is that:</p>
  
  <pre><code>f.Write("{0:0.#####} {0:0.#####} ...", a, a, ...);
  </code></pre>
  
  <p>duplicates the first object after the string, so I get all of numbers as 'a', even if I write</p>
  
  <pre><code>f.Write("{0:0.#####} {0:0.#####} ...", a, b, ...);
  </code></pre>