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.Reflecti on;
namespace BlogSample {
public class App {
public static string res() {
return "";
}
public static void Main() {
System.Type t = System.Type.Get Type("BlogSampl e.App");
System.Reflecti on.MethodInfo mi = t.GetMethod("re s",
System.Reflecti on.BindingFlags .Static);
// mi is null. Why ?
string s = (string)mi.Invo ke(null, null);
}
}
}
To test it I created the following sample but GetMethod() returns null.
Why ?
Andrus.
using System.Reflecti on;
namespace BlogSample {
public class App {
public static string res() {
return "";
}
public static void Main() {
System.Type t = System.Type.Get Type("BlogSampl e.App");
System.Reflecti on.MethodInfo mi = t.GetMethod("re s",
System.Reflecti on.BindingFlags .Static);
// mi is null. Why ?
string s = (string)mi.Invo ke(null, null);
}
}
}
Comment