C # Delegate

Source: Internet
Author: User

A good memory is better than a bad pen, write to the impression of a deeper.

Commissioned

  1. A custom data structure that uses the keyword delegate definition, in the form of a delegate return type delegate name (parameter list), whose return type and argument list need to be consistent with the delegate method, using the procedure to define-declare-initialize-Invoke. The delegate stores the address of the method, which is the reference type, and when a delegate is invoked, the program automatically executes its stored method.
  2. Delegates are initialized in several ways as the C # version changes
    delegate int Mydel (int a,int b);      Define the delegate Mydel _mydel;                         Statement _mydel=new Mydel (FUN1);              Initialization Method 1
    _MYDEL=FUN1; Initialization method 2_mydel (A, b); Call
  3. Delegates can use the + = and-= bindings and Unbind methods
    _mydel+=fun2;            On the basis of the original Fun1 and binding Fun2, sequential execution _mydel-=fun2;            To unbind Fun2, there's only Fun1.

C # Delegate

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.