Delegate:
1. delegate is a data type, just like a class {delegate variable types can be declared}
2. deleate keyword definition delegate: public delegate void MethodDelegate (); // This defines a delegate
If there is no return value for the method to be stored for this delegate in the future, the delegate should also be defined as void, and no parameters can be passed in the future.
3. Delegate: an external code can be embedded inside a code. Injection. (The delegate only extracts the changes in the method. Easy to write General Code .)
4. Use delegation when returning values between job forms
Job 2: print an array and use delegation. 09 delegate case-modify each string in the string array cyclically
Job 3: 10 use a delegate to implement a general comparison method (Max)
Job 5:
Anonymous Method
Xxx md = delegate ()
{
Console. WriteLine ("HAHAHA, I am an anonymous method !");
}
Lambda expressions:
Interview question: your understanding of lambda expressions:
Lambda is actually an anonymous function. during compilation, the lambda expression is compiled into a c # anonymous method, but using lambda expressions reduces the amount of code in many cases.