What is the yield keyword used for in C#?

后端 未结 17 1684
盖世英雄少女心
盖世英雄少女心 2020-11-22 05:26

In the How Can I Expose Only a Fragment of IList<> question one of the answers had the following code snippet:

IEnumerable FilteredList()
{
         


        
      
      
      
17条回答
  •  别那么骄傲
    2020-11-22 05:38

    Iteration. It creates a state machine "under the covers" that remembers where you were on each additional cycle of the function and picks up from there.

提交回复
热议问题