a list of dynamic functions and dynamically calling them

前端 未结 3 1134
长发绾君心
长发绾君心 2021-02-18 20:45

I would like to be able to store various static methods in a List and later look them up and dynamically call them.

Each of the static methods has different numbers of a

3条回答
  •  别那么骄傲
    2021-02-18 20:57

        List list = new List();
            Action myFunc = (int x, int y) => Console.WriteLine("{0}, {1}", x, y);
            Action myFunc2 = (int x, int y) => Console.WriteLine("{0}, {1}", x, y);
            list.Add(myFunc);
            list.Add(myFunc2);
    
            (list[0])(5, 6);
    

提交回复
热议问题