Delegates have come a long way since they were introduced in .NET 1.0. Back then they were only a way to refer to existing methods as variables. 2.0 allowed methods to be inlined, making them "anonymous." The 3.5 Framework does not introduce any new concepts regarding delegates, but it makes writing them much, much quicker [...]
Archive for the ‘lambdas’ Category
One of the hip new features of C# 3.0 is the built in support for lambdas:
Func<int> sq = x => x * x;
sq(5); // equals 25
This is very fancy, but sometimes you need to perform a lambda that has no argument. The syntax for that is simply "()".
Func<object> doStuff = () => Console.WriteLine("stuff has been [...]