Using yield in C#

前端 未结 4 740
粉色の甜心
粉色の甜心 2021-02-02 11:09

I have a vague understanding of the yield keyword in c#, but I haven\'t yet seen the need to use it in my code. This probably comes from a lack of understanding of

4条回答
  •  梦如初夏
    2021-02-02 12:09

    Also pretty good in testing and mocking when you just want to test an IEnumerable<> quickly, something like...

    yield return somevalue;
    yield return someothervalue;
    yield return yetanotherone;
    

提交回复
热议问题