Sunday, December 28, 2008

.NET: Implement IEnumerable to use a foreach? Not really.

To use your class with a foreach loop, you don't have to implement the IEnumerable interface - you simply have to write a public method that matches the signature:
public IEnumerator GetEnumerator()

The Microsoft guys probably thought they could sneak that past us, but they couldn't now, could they?

No comments: