Beispiel Enumerator (C#)

static IList<int> 
Merge (IList<int> xs, IList<int> ys) {
    IList<int> zs = new List<int>();
    IEnumerator<int> xi = xs.GetEnumerator();
    IEnumerator<int> yi = ys.GetEnumerator();
    bool xgo = xi.MoveNext(); 
    bool ygo = yi.MoveNext(); 
    // FIXME
    while (xgo && ygo) {
        if (xi.Current < yi.Current) {
    	    zs.Add(xi.Current); 
    	    xgo=xi.MoveNext();
        } else {
    	    zs.Add(yi.Current);
    	    ygo=yi.MoveNext();
        }
    }
    return zs;
}
Übungen:

2009-06-15