Vererbung und generische Polym. (I)

interface I { void P (); }
static void Q (IList<I> xs) 
    { foreach (I x in xs) { x.P(); } }
static void R<C> (Action<C> S, IList<C> xs)
    { foreach (C x in xs) { S(x); } }
für gleichzeitige Behandlung mehrerer Objekte
ist Vererbungspolymorphie meist ungeeignet

(z. B. Object.equals(Object o) falsch, Comparable<T>.compareTo(T o) richtig)



Johannes Waldmann 2014-03-31