title: C#: Compare text file contents to a string variable
body: <p>I have an application that dumps text to a text file.  I think there might be an issue with the text not containing the proper carriage returns, so I'm in the process of writing a test that will compare the contents of of this file to a string variable that I declare in the code.</p>
  
  <p>Ex:</p>
  
  <p>1) Code creates a text file that contains the text:</p>
  
  <pre class="lang-none prettyprint-override"><code>This is line 1
  This is line 2
  This is line 3
  </code></pre>
  
  <p>2) I have the following string that I want to compare it to:</p>
  
  <pre><code>string testString = "This is line 1\nThis is line 2\nThis is line3"
  </code></pre>
  
  <p>I understand that I could open a file stream reader and read the text file line by line and store that in a mutable string variable while appending "\n" after each line, but wondering if this is re-inventing the wheel (other words, .NET has a built in class for something like this).  Thanks in advance.</p>