c#反射

原文链接:https://my.oschina.net/u/2296689/blog/545759
void DynamicallyInvokeMembers(Assembly myAssembly)
{
Type classType = myAssembly.GetType(“Reflected”);
PropertyInfo myProperty
= classType.GetProperty(“MyProperty”);
MethodInfo propGet = myProperty.GetGetMethod();
object reflectedObject
= Activator.CreateInstance(classType);
propGet.Invoke(reflectedObject, null);
MethodInfo myMethod
= classType.GetMethod(“MyInstanceMethod”);
myMethod.Invoke(reflectedObject, null);
}

转载于:https://my.oschina.net/u/2296689/blog/545759

上一篇:C#--Invoke和BeginInvoke用法和区别


下一篇:MySQL 报错:Translating SQLException with SQL state '42000', error code '1064', mes