GetMethod() returns null

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top