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