C# supports anonymous functions, which can form closures. Anonymous functions are useful when you want to define a function inline without having to name it.
To run the program, compile and execute it:
In C#, closures are implemented using lambda expressions and delegate types. The Func<int> delegate represents a function that takes no parameters and returns an integer.
The IntSeq method returns a closure that increments and returns a counter. Each time you call IntSeq, you get a new closure with its own independent counter.
The last feature of functions we’ll look at for now is recursion.