2
Answers

yield return

George George

George George

16y
3.2k
1

Hello everyone,


I can not find too much materials about yield return. In MSDN sample,

http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx

what happens behind the scene of statement, "yield return result"?

I think what happens is a object instance which implements IEnumerable (collection pattern) interface is created (but what is the type of the instance? some C# internal type?), and each time "yield return result" is called, a new element is inserted into the internal array of the instance. Any more reference documents?


thanks in advance,
George

Answers (2)