C#.NET反射获取Form窗体中所有的方法Method|C/S开发框架
C#.NET反射获取Form窗体中所有的方法Method
var type = this.GetType();
var list = this.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.ToList().Where(w => w.DeclaringType == type).OrderBy(o => o.Name).ToList();
foreach (var method in list)
{
if (method.Name.ToUpper() == methodName.ToUpper())
{
method.Invoke(this, null);
return;
}
}
扫一扫加作者微信