C# 委托

 public delegate int ceshi(int a, int b);
        static int ax(int a, int b) {
            return a * b;
        }
        static int bx(int a, int b) {
            return a / b;
        }
        static void Main(string[] args)
        {
            ceshi wo;
            Console.WriteLine("请输入数");
            string c = Console.ReadLine();
            int d = c.IndexOf(" ");
            if (d > 0)
            {
                int a = Convert.ToInt32(c.Substring(0, d));
                int b = Convert.ToInt32(c.Substring(d + 1));
                Console.WriteLine("请输入M");
                c = Console.ReadLine();
                if (c.ToUpper() == "M")

                    wo = ax;


                else
                    wo = bx;

                Console.WriteLine(wo(a, b));
                Console.ReadKey();

            }
            else {
                Console.WriteLine("出来");
            
            }
            
        }
原文地址:https://www.cnblogs.com/mengluo/p/4791084.html