- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace 委托
- {
- class 委托数组
- {
- public delegate int MyDele( int value );
- public static void Main(string[] args)
- {
- MyDele[] dels = new MyDele[] { MyMathClass.CountMoney , MyMathClass.CountMoney2 };
- for (int i = 0; i < dels.Length; i++ )
- {
- //ProccesDele( dels[i] , 5 );
- Console.WriteLine( dels[i](5) );
- }
- Console.ReadLine();
- }
- //public static void ProccesDele( MyDele dele, int value)
- //{
- // int reint = dele( value );
- // Console.WriteLine( "结果:" + reint.ToString() );
- //}
- }
- class MyMathClass
- {
- public static int CountMoney(int money)
- {
- return money + money;
- }
- public static int CountMoney2(int money)
- {
- return money * money;
- }
- }
- }
C#中的委托数组
最新推荐文章于 2023-09-09 17:12:25 发布