110,536
社区成员
发帖
与我相关
我的任务
分享
namespace Common
{
public class Test
{
public string str { get; set; }
public void A()
{
str += "1";
Console.WriteLine(str);
}
public void B()
{
str += 2;
Console.WriteLine(str);
}
}
}
static void Main(string[] args)
{
Console.WriteLine("输入方法名");
string inputs = Console.ReadLine();
Assembly ass = Assembly.LoadFrom("Common.dll");
Type t = ass.GetType("Common.Test");
object ob = Activator.CreateInstance(t);
foreach (var item in inputs)
{
MethodInfo info = t.GetMethod(item.ToString());
info.Invoke(ob, new object[] { });
}
Console.ReadLine();
}