一直不知道也可以这样,今天看书发现的,也许比较弱智。![]()
1 public delegate void MyDelegate(int x,int y);
2 public static void Main(string[] args)
3 {
4 MyDelegate my1 = PrintPair;
5 my1(6,4);
6 }
7 static void PrintPair(int x,int y)
8 {
9 Console.WriteLine(x.ToString()+"\n"+y.ToString());
10 Console.Read();
11 }
原来我一直都是用委托实例的厄。。2 public static void Main(string[] args)
3 {
4 MyDelegate my1 = PrintPair;
5 my1(6,4);
6 }
7 static void PrintPair(int x,int y)
8 {
9 Console.WriteLine(x.ToString()+"\n"+y.ToString());
10 Console.Read();
11 }
1 public delegate void MyDelegate(int x,int y);
2 public static void Main(string[] args)
3 {
4 MyDelegate my1 = new MyDelegate(PrintPair);
5 my1(6,4);
6 }
7 static void PrintPair(int x,int y)
8 {
9 Console.WriteLine(x.ToString()+"\n"+y.ToString());
10 Console.Read();
11 }
这样更像是委托链嘛 orz
2 public static void Main(string[] args)
3 {
4 MyDelegate my1 = new MyDelegate(PrintPair);
5 my1(6,4);
6 }
7 static void PrintPair(int x,int y)
8 {
9 Console.WriteLine(x.ToString()+"\n"+y.ToString());
10 Console.Read();
11 }
浙公网安备 33010602011771号