Пример #1
0
 public string doOpertion(string operationName, int numb1, int numb2)
 {
     object[] mParam = new object[] { numb1, numb2 };
     var myClassObj = new MyClass();
     var myTpyeObj = myClassObj.GetType();
     var myMethodInfo = myTpyeObj.GetMethod(operationName);
     return myMethodInfo.Invoke(myClassObj, mParam).ToString();
 }
Пример #2
0
        static void Main(string[] args)
        {
            var instance = new MyClass();
            WriteLine(instance.doOpertion("AddNumb", 3, 5));
            WriteLine(instance.doOpertion("SubNumb", 7, 2));

            WriteLine("Done.");
            ReadLine();
        }