Please enable JavaScript.
Coggle requires JavaScript to display documents.
Delegates and Lamda - Coggle Diagram
Delegates and Lamda
Lamda Expression
This is a shorthand, we use in the replace of Anonymous Type
-
(p1,p2)=>(p1+p2) example for multiple input expression
-
In C# we can treat a function like any other types - assign them to variables or pass them parameters
-
Anonymous Function
Using Delegate
Func<int a,int b) func=delegate(int a){return a+a};
Using Function
Func<int a,int b) func=(int a)=>a+a;
Delegates
-
-
A variable of delegate type can only be assigned a method with a signature described in the delegates
Advantages
-
-
-
-
They're used in events, where methods are called when an event occurs
-
Delegates is a special type whose instance hold a reference to a method with particular parameter list and return types
-
-
-
-