摘要:
一、委托委托类似于函数指针,但函数指针只能引用静态方法,而委托既能引用静态方法,也能引用实例方法。委托使用分三步:1、委托声明。2、委托实例化。3、委托调用。例程一:程序代码using System;namespace 委托{ delegate int NumOpe(int a,int b);//第一步:委托声明 class Class1 { static void Main(string[] args) { Class1 c1 = new Class1(); NumOpe p1 = new NumOpe(c1.Add);//委托实例化,注意参数是要使用的参数名,且不带括号 Console.W 阅读全文