Simple Let Example : Let « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   
            Int32[] ArrayA = { 1, 2, 3, 4 };
            Int32[] ArrayB = { 1, 2, 3, 4 };

            var Squares = from QueryA in ArrayA
                from QueryB in ArrayB
                let TheSquare = QueryA * QueryB
                where TheSquare > 4
                select new { QueryA, QueryB, TheSquare };

            foreach (var ThisSquare in Squares)
                Console.WriteLine(ThisSquare.QueryA.ToString() + " * " + 
                   ThisSquare.QueryB.ToString() + " = " + 
                   ThisSquare.TheSquare.ToString());


   }
}








22.4.Let
22.4.1.Simple Let Example