The proxy (delegate) in C)

Source: Internet
Author: User

Some books are also called "representatives" or "delegation ".
C # removes the pointer concept. Programmers who are reluctant to give pointers can have two solutions: declare "unsafe) the code segment then uses a pointer or a reference type of C #-"proxy" (delegate ). "Proxy" is equivalent to the function pointer prototype in C. The difference is that C # is type-safe.
"Proxy" (delegate): "proxy" is type-safe and fully object-oriented.
(1) in C #, all proxies are derived from the System. Delegate class (delegate is the alias of System. Delegate ).
(2) The proxy has an implicit sealed attribute, that is, it cannot be used to derive a new type.
(3) The biggest role of proxy is to bind event handlers to class events.
(4) Before calling a function through a proxy, you must first check whether the proxy is null. If it is not null, you can call the function. (5) static methods or instance methods can be encapsulated in the proxy instance.
(6) When creating a proxy instance, you must pass the method to be mapped or other proxy instances to specify the prototype of the function to be encapsulated by the proxy (. NET is called the method signature: signature

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.