lambda syntax
In this chapter you will learn:
Syntax of lambda
Lambda has the following syntax.
(parameters) => expression-or-statement-block
The parameters
are defined by the delegate and the
return type of expression-or-statement-block
must be consistant with delegate return type.
We can use return type in lambda expression.
using System;//j a v a 2 s. com
delegate int Calculate(int i);
class Program
{
public static void Main()
{
Calculate c = x => {return x + 1;}
Console.WriteLine(c(1));
}
}
The result:
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » delegate, lambda, event