using System;
using System.Collections.Generic;
// some class which has a method that _does stuff_
public class Foo
{
public void DoThing()
Console.WriteLine("I did a thing!");
}
public class Program
public static void Main()
// list of Foo we'd want to eventually _do stuff_ with
List<Foo> fooList = new();
// we could do this currently by going
fooList.ForEach(f => f.DoThing());
// but what about in the form (this is currently invalid)
fooList.GetAll().DoThing();
// the above could be made to work by uising the following bastadised extension methods but it is not DRY
// add a GetAll only for a List of Foo. This sucks since it's not really "getting all" jsut returning an enumerator.
// public static List<T>.Enumerator GetAll<T>(this List<T> list) where T : Foo
// {
// return dictionary.GetEnumerator();
// }
// this also sucks since instead of being able to call the existing DoThing we redefine it (and now have to keep it in-sync)
// public static void DoThing<T>(this List<T>.Enumerator listEnum) where T : Foo
// while (listEnum.MoveNext())
// listEnum.Current.Value.DoThing();