C # Delegate Events

Source: Internet
Author: User

1. Delegate Event Keyword: delegate

2. When declaring a function, add the following function type

Example: public delegate int Test (int x,int y)

3. Define the delegate variable: Test T1, the delegate receives a method reference.

4. A delegate variable can be called as a function. With Assignment "="

Delegate variable = function name

5. A variable of a delegate type can refer to any method that satisfies the requirement, similar to a C-language function pointer.

6. A delegate variable can use "+ =" to hook up multiple methods, or you can use "-=" to dynamically remove a reference to a method.

7. Delegate variables that refer to multiple methods are called "Multipath delegates."

8. The essential feature of a delegate is one-to-many, one-delegate-to-multiple methods.

C # Delegate Events

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.