本帖最后由 QQ757400993 于 2010-04-08 17:58:43 编辑

解决方案 »

  1.   

    反射中MethodInfo 就是方法了
      

  2.   

    别怕,爱因斯坦小时候的问题也很奇怪。你的方法如果是都一样的,那调一个就好,没有必要写50个。如果有些不同,可以考虑循环,或者参数。如果大不同,老实一个个写,windows XP 也不是一个方法完成的。有时候程序也不是为了“华丽代码”,要写的还是一步步来。注:头昏中,想啥说啥,奇怪问题奇怪回答。
      

  3.   

    我觉得你可以那样用,但是用时,需要处理一下,就是把方法变对对象如:Say();存入进:"Say();"这样就行了
    用的时候再把""去掉就行了这样是可行,你可以试试
      

  4.   

    1、可以用反射来实现这种效果
    2、把委托存起来试试的private delegate void DelegateMethod(string param);        static void Main(string[] args)
            {
                
                List<DelegateMethod> listMethod = new List<DelegateMethod>();
                DelegateMethod method = new DelegateMethod(Method1);
                listMethod.Add(method);
                method = new DelegateMethod(Method2);
                listMethod.Add(method);
                method = new DelegateMethod(Method3);
                listMethod.Add(method);
                method = new DelegateMethod(Method4);
                listMethod.Add(method);
                method = new DelegateMethod(Method5);
                listMethod.Add(method);
                foreach (DelegateMethod methoditem in listMethod)
                {
                    methoditem.Invoke("hello world");
                }
                Console.ReadKey();
            }        static void Method1(string param)
            {
                Console.WriteLine("Method1" + param);
            }
            static void Method2(string param)
            {
                Console.WriteLine("Method2" + param);
            }
            static void Method3(string param)
            {
                Console.WriteLine("Method3" + param);
            }
            static void Method4(string param)
            {
                Console.WriteLine("Method4" + param);
            }
            static void Method5(string param)
            {
                Console.WriteLine("Method5" + param);
            }
      

  5.   

    Dictionary<(TKey, TValue>)>保存参数和函数
    通过反射调用相关方法