The quest for a succint, readable expression of Next in a sequence I have a need to express something like this:

while(bytesToWrite &gt; 0)
{
    // get the NEXT location to write from a Key/Value collection of locations

    // read a packet from a file at the specified location

    // write some bytes to the packet

    bytesToWrite -= bytesWritten
}


This was my first attempt:

var dictionary = new Dictionary&lt;long, long&gt;() { .. }
...

while(bytesToWrite &gt; 0)
{
    var pin = dictionary.Take(1).First();
    Debug.Print(pin.Key.ToString() + ", " + pin.Value.ToString());

   // Write the bytes using Key and Value for location information.

    dictionary = dictionary.Skip(1)
    bytesToWrite -= bytesWritten;
}


But it doesn't look terribly efficient to me.  It looks like I'm making a new collection each time through the loop, just to peel off a single item, and the Take(1).First() and dictionary = dictionary.Skip(1) syntax is a bit awkward.

If I put my original collection in a LinkedList, I can do this:

var map = new LinkedList&lt;KeyValuePair&lt;long, long&gt;&gt;(dictionary);
...
var pin = map.First;
while (pin != null &amp;&amp; bytesToWrite &gt; 0)
{
    // Value.Key and Value.Value??
    Debug.Print(pin.Value.Key.ToString() + ", " + pin.Value.Value.ToString());

    // Write the bytes

    pin = pin.Next;
    bytesToWrite -= bytesWritten;
}


Eww.  Value.Key and Value.Value is not exactly intuitive.

I can write a couple of wrapper classes, like so:

public class StateList&lt;T&gt;
{
    LinkedList&lt;T&gt; list;
    LinkedListNode&lt;T&gt; currentNode;

    public StateList(IEnumerable&lt;T&gt; source)
    {
        list = new LinkedList&lt;T&gt;(source);
    }

    public StateList&lt;T&gt; Create&lt;T&gt;(IEnumerable&lt;T&gt; source)
    {
        return new StateList&lt;T&gt;(source);
    }

    public T First
    {
        get
        {
            var node = list.First;
            return Value(node);
        }
    }

    public T Last
    {
        get
        {
            var node = list.Last;
            return Value(node);
        }
    }

    public T Next
    {
        get
        {
            var node = currentNode.Next;
            return Value(node);
        }
    }

    public T Previous
    {
        get
        {
            var node = currentNode.Previous;
            return Value(node);
        }
    }

    public T Value(LinkedListNode&lt;T&gt; node)
    {
        if (node != null)
        {
            var value = node.Value;
            currentNode = node;
            return value;
        }
        return default(T);
    }
}

public static class StateList
{
    public static StateList&lt;T&gt; Create&lt;T&gt;(IEnumerable&lt;T&gt; source)
    {
        return new StateList&lt;T&gt;(source);
    }
}


and get the code look like this:

var map = StateList.Create(dictionary);
...
var pin = map.First;
while (bytesToWrite &gt; 0)
{
    // Ah, that's better.
    Debug.Print(pin.Key.ToString() + ", " + pin.Value.ToString());

    // Write the bytes

    // Pin is taken from the map, not from the previous pin.
    pin = map.Next;
    bytesToWrite -= bytesWritten;
}


Ah, that's much better.  The question is, is all that ceremony really worth it?  I feel like I'm missing something simple and obvious.  

I'd also like comments on the relative merit of the StateList class, whether it is a satisfactory approach from a good practices viewpoint, or a terrible abomination.
It sounds like what you want is a foreach over the Dictionary, combined with a break for the bytesToWrite condition.

foreach (var pin in dictionary)
{
    if (bytesToWrite &lt;= 0)
        break;

    Debug.Print(pin.Key + ", " + pin.Value);

    // Write the bytes using Key and Value for location information.

    bytesToWrite -= bytesWritten;
}