title: How to replace NewLine in .NET for Linux NewLine
body: <p>I have a string in .NET defined like this:</p>
  
  <pre><code>var str = @"line 1
  line 2
  line 3";
  </code></pre>
  
  <p>I want to replace the Windows newline character for the Linux equivalent. (replacing <code>\r\n</code> for just <code>\n</code>).</p>
  
  <p>I tried <code>var str2 = str.replace(Environment.NewLine, "\n");</code> but the result is exactly the same string (str == str2 is true).</p>
  
  <p>I guess that Windows replaces <code>\n</code> in strings with <code>\r\n</code>, effectively changing nothing. </p>
  
  <p>I tried <code>var str2 = str.replace(Environment.NewLine, '\n');</code> but gives compilation errors because one parameter is a string and the other is a char.</p>
  
  <p>I even tried <code>var str2 = str.replace(Environment.NewLine, '\n'.ToString());</code> but that did not work either.</p>
  
  <p>Ideas?</p>