If your query's lambda expressions reference local variables, these variables are subject to outer variable semantics. : Lambda : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Lambda »

 

If your query's lambda expressions reference local variables, these variables are subject to outer variable semantics.








    
 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        int[] numbers = { 1, 2 };

        int factor = 10;
        IEnumerable<int> query = numbers.Select(n => n * factor);

        factor = 20;
        foreach (int n in query) Console.Write(n + "|");   
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Lambda