How can I abandon an IEnumerator without iterating to the end?
<p>Consider the following code, the first demonstrates that the "cleanup" executes when we're finished iterating over the IEnumerable of strings.  The second pass is what is causing me grief.  I need to be able abandon the IEnumerable before reaching the end, and then have the clean up code execute.  But if you run this you'll see that in the second pass the clean up never fires.</p>

<p>What is the preferred way of abandoning an IEnumerable like this?</p>

<pre><code>static void Main(string[] args)
{
    // first pass
    foreach (String color in readColors())
        Console.WriteLine(color);

    // second pass
    IEnumerator&lt;string&gt; reader = readColors().GetEnumerator();
    if (reader.MoveNext())
    {
        Console.WriteLine(reader.Current);
        reader.Dispose();
    }
}
static IEnumerable&lt;string&gt; readColors()
{
    string[] colors = { "red", "green", "blue" };
    for (int i = 0; i &lt; colors.Length; i++)
        yield return colors[i];

    Console.WriteLine("Cleanup goes here");
}
</code></pre>
