When writing an enumerable, what does yield return var?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/39476/what-is-the-yield-keyword-used-for-in-c">What is the yield keyword used for in C#?</a>  </p>
</blockquote>



<p>Say I have code that looks like:</p>

<p>(steam is a filestream)</p>

<pre><code>using(BinaryWriter bw = new BinaryWriter(stream))
{
  foreach(byte[] b in BreakBytes(objectOfBytes))
  {
    writer.Write(b);
  }
}
</code></pre>

<p>So for BreakBytes to work, it has to do something like:</p>

<pre><code>public static IEnumerable&lt;byte[]&gt; BreakBytes(byte[] b)
{
  ..
  while(..) {

     yield return some_buffer;

  }
  ..
}
</code></pre>

<p>What exactly is yield doing?  Does it keep track of where it was position wise?</p>

<p>I believe it is return to the calling foreach loop, but continues to the next iteration when called again?</p>
