A lambda expression.
Lambda expressions are new to c#3.0 (Java is JDK8 to support), and it's not surprising if you've learned c#2.0 before. Here are some versions of the C # language and Visual Studio information:
C # 1.0 with Visual Studio.NET
C # 2.0 with Visual Studio 2005
C # 3.0 with Visual Studio 2008,2010 (. NET 2.0, 3.0, 3.5)
C # 4.0 with Visual Studio (. NET 4)
C # 5.0 with Visual Studio (. NET 4.5), (. NET 4.5.1, 4.5.2)
C # 6.0 with Visual Studio (. NET 4.6, 4.6.1, 4.6.2)
C # 7.0 with Visual Studio (. NET 4.6.2, 4.7)
Give you an example.
For example, I define a delegate:
delegate int Method (int a, int b);
Then define a method:
int Add (int a, int b)
{
return a + B;
}
I may need to invoke this method through a delegate:
Method m + = ADD;
Console.WriteLine (M (2, 3));
====================================================
But if you use a LAMBDA expression:
Method m + = (A, b) = + A + b;
Console.WriteLine (M (2, 3));
The definition of the method can be omitted.
In fact, a LAMBDA expression simply simplifies the syntax of an anonymous method.
anonymous method syntax with C # 2.0:
Method m + = delegate (int a, int b) {return a + B;};
Console.WriteLine (M (2, 3)); *******************************************************************************C # + = (s, e) = = What do these characters mean?Public MainWindow ()
{
InitializeComponent ();
This. Loaded + = (s, e) = Discoverkinectsensor ();
This. Unloaded + = (s, e) = = This.kinect = null;
In the above code, + = Adds a delegate to the delegate chain, (s,e) + = is a lambda expression that creates a delegate that is the subject of the delegate process, which is the part that follows.
In fact, this is the equivalent
This. Loaded + = new EventHandler (form_loaded);
private void Form_loaded (object sender, EventArgs e) {
Discoverkinectsensor ();
} original link: the role of = = in C #
Use of lambda expressions in "C #" C #