GetMethod() returns null

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrus

    #1

    GetMethod() returns null

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


  • Marc Gravell

    #2
    Re: GetMethod() returns null

    try using BindingFlags.St atic | BindingFlags.Pu blic
    (bitwise OR)

    Marc


    Comment

    Working...