1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespaceDelegate7 {8 Public Delegate intAaintAintb);9 class ProgramTen { One Static voidMain (string[] args) A { - /*FANGFA bb = new FANGFA (); - aa cc = BB.JIAFA;*/ //Original Wording theAA cc =NewFANGFA (). Jiafa;//Simplified notation - //The method must be the same as the delegate structure to delegate, for example here both are int types - //addition - intA = CC (5,6); + Console.WriteLine (a); - //Subtraction +AA dd =NewFangfa (). Jianfa; AA = DD (5,6); at Console.WriteLine (a); - - //Mixed Operations -A = CC (5,4)-DD (5,4); - Console.WriteLine (a); - in - console.readline (); to //delegate: Gets the action execution function, such as getting the mouse click action, executing a function + //The delegate is the agent, click the event is a special delegate, special in can receive the user's action - the } * $ }Panax Notoginseng}
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespaceDelegate7 {8 classFANGFA9 {Ten Public intJiafa (intAintb) One { A returnA +b; - } - Public intJIANFA (intAintb) the { - returnAb; - } - } +}
6.20 delegates