C#根据函数名称执行对应的函数

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Reflection;
 4 
 5 namespace test
 6 {
 7     public class test
 8     {
 9         public static void RunSchedule()
10         {
11             test type = Activator.CreateInstance(typeof(test), true) as test;
12 
13             MethodInfo method = type.GetType().GetMethod("f1");
14             method.Invoke(type, null);
15         }
16         private void f1()
17         {
18 
19         }
20         private void f2()
21         {
22 
23         }        
24     }
25 }

 

posted @ 2014-03-12 11:16  erictanghu  阅读(793)  评论(0编辑  收藏  举报