yield return vs. return IEnumerable

后端 未结 2 1524
礼貌的吻别
礼貌的吻别 2021-02-19 07:02

I\'ve noticed something curious about reading from an IDataReader within a using statement that I can\'t comprehend. Though I\'m sure the answer is simple.

2条回答
  •  萌比男神i
    2021-02-19 07:39

    It's because the "yield return" will return one element and continue the iteration, while the "normal" return will finish the invocation.

提交回复
热议问题