Mega Code Archive

 
Categories / C# / LINQ
 

A lambda expression can reference the local variables and parameters of the method in which its defined

using System; delegate int NumericSequence(); class Test {     static void Main() {         int seed = 0;         NumericSequence natural = () => seed++;         Console.WriteLine(natural());         Console.WriteLine(natural());     } }