How To Implement IEnumerable Interface and yield Keyword

This sample shows how to create a list class which implements IEnumerable<int> and the yield keyword to enable foreach iteration over the contents of the list. Two properties are defined, one returning the odd numbers, the other returning the even numbers.

C# (40.7 KB)
4 Star
1,057 times
Add to favorites
E-mail Twitter Digg Facebook