title: Does C# support inout parameters?
body: <p>In C#, I am using a <code>StreamReader</code> to read a file, line per line. I am also keeping the current line's number in an <code>int</code>, for reports of possible error messages.</p>
  
  <p>Reading each line goes along with some tests (for instance, lines beginning with <code>#</code> are comments, and need to be skipped), so I am planning to place the whole reading procedure in a function, which will keep reading until it encounters a useful line, and then returns that line. If it encounters <code>EOF</code> it will simply return <code>null</code>.</p>
  
  <p>I thought I was being clever when I defined this function as <code>string read(StreamReader sr, out int lineNumber)</code>, but now it turns out that C# won't be able to do something like <code>lineNumber++</code> inside that function. It assumes that the variable has not been assigned yet, probably because it has no way to know whether it has been assigned in advance of this function call.</p>
  
  <p>So, the problem is simple: how can I specify that this variable is an <code>inout</code> parameter (I think that's the term; I've heard it being mentioned in the context of other programming languages)? Is this even possible in the first place? <strong>I am absolutely not going to make <code>lineNumber</code> a member of my class</strong>, so that is not an option.</p>