Tuesday, April 22, 2008

yield return iterator

IL creates a state engine to retain their state and don't have to go through the pain of maintaining state in coding:


private static IEnumerable GetData()
{
for (int i=0; i <5; i++)
yield return i ;
}

when call GetData() function, will receive a new incremented integer.

No comments: