I've given this interface some thought, the benefits to using it seem to be
01: I can use "var" in a foreach
//Works
List<SomeClasslist = new List<SomeClass>();
foreach(var item in list)
item.MethodOnSomeClass();
//Doesn't work
ArrayList list2 = new ArrayList();
foreach(var item in list2)
item.MethodOnSomeClass(); //item is treated as System.Object
02: Type checking
//This compiles
ArrayList list2 = new ArrayList();
list2.Add(new Person());
foreach(NotAPersonClass item in list2)
item.MethodOnNotAPersonClass();
//This does not compile
List<Personlist = new List<Person>();
foreach(NotAPersonClass item in list)
item.MethodOnNotAPersonClass();
Are there any other benefits of IEnumerable<Tover IEnumerable that I have
not considered?
Pete