A
Andrus
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);
}
}
}
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);
}
}
}