|
by Brendan Enrick via Brendan Enrick on 10/27/2009 2:00:00 PM
Working with a foreach loop is the primary reason to implement the IEnumerable and IEnumerator interfaces. You’ll want one of each of these to work with the loop. I am going to do an example DateRange class which will implement IEnumerable<DateTime> and will allow us to iterate through a non-existent collection of DateTime objects. Note: I am aware of the fact that I could achieve the same result with a for loop. I find the foreach loop more readable. First we need to create a basic Da
... [ read more ]
|