title: Passing a StreamReader object by Reference
body: <p>I'm creating a small file parsing console app using C# in VS 2013.  I'm using <code>StreamReader</code> to read in the file and creating objects from data in the file by parsing the lines.  </p>
  
  <p>I call a method, <code>CreateHeader()</code>, to create a Header object and pass the <code>StreamReader</code> object to read those particular lines, create a Header object, and return the object to the calling method.  I'm passing the <code>StreamReader</code> object by reference because I'm wanting the <code>StreamReader</code> to be updated in the calling method to get the next line in the file where the <code>CreateHeader()</code> method left off.  However, when the object is returned to the calling method, the <code>StreamReader</code> object wasn't updated and it still is at the same line in the file when the <code>CreateHeader()</code> method was called.  </p>
  
  <p>How would I pass a <code>StreamReader</code> object to another function and have that <code>StreamReader</code> be updated in the calling function?  Here is some sample code:</p>
  
  <pre><code>static Header CreateHeader(ref StreamReader sr)
  {
      Header hd = new Header();
  
      string formTitle = string.Empty;
      string[] words;
      string _line = string.Empty;;
  
      for(int x = 0; x &lt; 5; x++)
      {
          _line = sr.ReadLine();
          Console.WriteLine(_line);
      }
  }
  
  static void ParseLines()
  {
      Header _hd = CreateHeader(ref sr);
      _line = sr.ReadLine();
      prodList = new List&lt;InventoryActivityProducts&gt;();
  }
  </code></pre>