Alex Meyer-Gleaves

Two simple tips for working with LINQ and IEnumerable<T>

on c#, LINQ

Meet the test subject Let’s create a simple class that returns the numbers from 1 to 100. public class Loopy { public int Enumerations { get; private set; } public IEnumerable<int> GetSome() { foreach (int number in Enumerable.Range(1, 100)) { Enumerations++; yield return number; } } } We use Enumerable.Range to grab the numbers from 1…