GetMethod() returns null - Andrus

06-Aug-07 09:02:01
I need to call method by its name as string.
To test it I created the following sample but GetMethod() returns null.

Why ?

Andrus.

using System.Reflection;

namespace BlogSample {

public class App {

public static string res() {
return "";
}

public static void Main() {

System.Type t = System.Type.GetType("BlogSample.App");
System.Reflection.MethodInfo mi = t.GetMethod("res",
System.Reflection.BindingFlags.Static);
// mi is null. Why ?
string s = (string)mi.Invoke(null, null);
}
}
}
button
 
 

GetMethod() returns null - Marc Gravell

06-Aug-07 09:23:31
try using BindingFlags.Static | BindingFlags.Public
(bitwise OR)

Marc
button
 
Type.IsValueType