Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object May 2010 Entries
How to: Invoke a method by name

Type myType = typeof(MyClass);

string methodName = "methodNameAsString";

MethodInfo myTypeGetMethod = myType.GetMethod(methodName);

MyClass obj = new MyClass();

object[] parms = { 123, "string test"};

myTypeGetMethod.Invoke(obj, args);
 

 

Posted On Monday, May 31, 2010 8:41 AM

Copyright © Sglima | Powered by: GeeksWithBlogs.net | Join free