On Aug 31, 12:37 pm, cody <deutron...@gmx.dewrote:
Why was this design decision to use this kind of "duck typing" in that case?
So that you could do strongly typed enumerations (including there
being no boxing penalty) before generics came along.
I suspect that if it was designed today with generics already present,
it wouldn't be done the same way. Having said that, I believe the
query expression transformations performed by the C# 3 compiler
require appropriate method names but not any particular interface.
All you have to do is have a method GetEnumerator() which returns an
object providing Current and MoveNext(). IEnumerator and IEnumerable are
not necessary. Why is that? And what are these interface good for then?
Just dummy/marker interfaces like Cloneable in java?
No, there are lots of things which *do* require IEnumerable. It's not
just for foreach!
Jon