Thread: yield return

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    yield return

    Hello everyone,


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

    http://msdn.microsoft.com/en-us/libr...f0(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

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    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)?

    Quote Originally Posted by nvoigt View Post
    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

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    And don't full quote me.
    Like if that changed something...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Hi vart, :-)


    Any comments to my post #3?

    Quote Originally Posted by vart View Post
    Like if that changed something...

    have a good weekend,
    George

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Sorry for any in-convenience, nvoigt!


    I will improve in the future. :-)


    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  3. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM
  4. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM
  5. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 01:54 AM