[Study diary]. Net basics enhanced for 09 days

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.