问题
Is yield return
a shortcut for implementing IEnumerable
and IEnumerator
?
回答1:
Yes, it is.
You can find out a lot more about it in chapter 6 of my book, C# in Depth. Fortunately chapter 6 is available for free from Manning's web site.
I also have two other articles on the book's web site.
Feedback welcome.
回答2:
To add to the link-fest, Raymond Chen did a nice little series on C# iterators a few months ago:
- http://blogs.msdn.com/oldnewthing/archive/2008/08/12/8849519.aspx
- http://blogs.msdn.com/oldnewthing/archive/2008/08/13/8854601.aspx
- http://blogs.msdn.com/oldnewthing/archive/2008/08/14/8862242.aspx
- http://blogs.msdn.com/oldnewthing/archive/2008/08/15/8868267.aspx
回答3:
Yes. See the following for a starter
http://msdn.microsoft.com/en-us/library/dscyy5s0.aspx
来源:https://stackoverflow.com/questions/288808/is-yield-return-ienumerable-ienumerator