mercredi 11 mars 2015

Finding a private method in a Base Class via reflection

How can I find my method "button_Click" by name? If I make it public, it works, but I would rather have it private.



class Test : BaseTest
{
public Test()
{
LoadMethod();
}
}

class BaseTest
{
public void LoadMethod()
{
//WHY IS THIS NULL???
var eventMethod = GetType().GetMethod("button_Click", BindingFlags.NonPublic | BindingFlags.Instance);
}

void button_Click(object sender, EventArgs e) { }
}





Aucun commentaire:

Enregistrer un commentaire