A lambda expression can reference the local variables and parameters of the method in which it's defined.
using System;
delegate int NumericSequence();
class Test {
static void Main() {
int seed = 0;
NumericSequence natural = () => seed++;
Console.WriteLine(natural());
Console.WriteLine(natural());
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
|