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

时间:2023-03-08 23:40:19
C#根据函数名称执行对应的函数
 using System;
using System.Collections.Generic;
using System.Reflection; namespace test
{
public class test
{
public static void RunSchedule()
{
test type = Activator.CreateInstance(typeof(test), true) as test; MethodInfo method = type.GetType().GetMethod("f1");
method.Invoke(type, null);
}
private void f1()
{ }
private void f2()
{ }
}
}