View Full Version : yield return
George2
05-01-2008, 08:21 AM
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
nvoigt
05-02-2008, 03:01 AM
Clicking the first link on the page you gave is a page telling you what it does behind the scenes. Just two clicks further is a page telling you to look in your VS directory to find the C# language specification in your language and have a look at section 19 and 22. Do you need any more details, or did you just need somebody to do the clicking for you ? Really, please, learn to look stuff up. And don't full quote me.
George2
05-03-2008, 01:39 AM
Great nvoigt!
I have also made some study from sample expansion of code from C# specification, at top of this page,
http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx
especially 10.14.6 implementation examples.
My current confusion is, I think the yield return grammar is of too flexibility, any ideas in what situation should we use it (in the implementation samples, it is used in for loop, while loop and foreach loop, too flexibility to grasp)?
Clicking the first link on the page you gave is a page telling you what it does behind the scenes. Just two clicks further is a page telling you to look in your VS directory to find the C# language specification in your language and have a look at section 19 and 22. Do you need any more details, or did you just need somebody to do the clicking for you ? Really, please, learn to look stuff up. And don't full quote me.
regards,
George
And don't full quote me.
Like if that changed something...
George2
05-03-2008, 09:08 AM
Hi vart, :-)
Any comments to my post #3?
Like if that changed something...
have a good weekend,
George
nvoigt
05-05-2008, 12:25 AM
What he probably meant to say was "make it idiot proof and someone will make a better idiot".
I don't think you read my text. Or you have serious problems understanding it. What was so hard about "don't full quote me" ? You are looking like someone who cannot use a forum (or any other form of internet communication) properly. I told you two times that quoting people in full makes you look like an idiot. Yet you do. You even quote me on it. I will not try again.
Go ahead and do dumb things, I will not help people who do not care.
George2
05-07-2008, 07:16 AM
Sorry for any in-convenience, nvoigt!
I will improve in the future. :-)
regards,
George
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.