mardi 16 octobre 2018

C# get private method by reflection from another class and invoke it

In Java you can invoke a private method like so:

Method m = obj.getClass().getDeclaredMethod("foo", null); 
m.setAccessible(true);
m.invoke("bar");

What is the equivalence in C#? I need to call a private method in the Unit Test.





Aucun commentaire:

Enregistrer un commentaire