most query operators is that they execute not when constructed, but when enumerated

image_pdfimage_print
   
 

using System;
using System.Collections.Generic;
using System.Linq;

public class MainClass {
    public static void Main() {
        var numbers = new List<int>();
        numbers.Add(1);
        IEnumerable<int> query = numbers.Select(n => n * 10);
        numbers.Add(2);             
        foreach (int n in query)
            Console.Write(n + "|"); 
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.