April 2007 Entries

Upon Reflection - C# yields statement enumeration helper
The new yields statement sounds very convenient. In the past, one had to write a significant amount of code to implement the IEnumerator interface and expose an enumerator. That included considerations of concurrency, a loop variable bound to the instance or other methods to maintain current loop value during enumeration. Fret no more, a new syntax is in town - the yields statement. With the yields statement, IEnumerator implementation folds down to a scan one liner: public class MyCollection : IEnumerable ......

Posted On Monday, April 16, 2007 2:19 AM | Comments (3)