C# IEnumerator/yield structure potentially bad?

前端 未结 11 1313
面向向阳花
面向向阳花 2021-02-01 02:47

Background: I\'ve got a bunch of strings that I\'m getting from a database, and I want to return them. Traditionally, it would be something like this:

public Li         


        
11条回答
  •  旧时难觅i
    2021-02-01 03:28

    Slightly more concise way to force evaluation of iterator:

    using System.Linq;
    
    //...
    
    var stuff = GetStuff(connectionString).ToList();
    

提交回复
热议问题