Is Yield Return == IEnumerable & IEnumerator?

你说的曾经没有我的故事 提交于 2019-12-03 04:13:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!