[Solved] How to create type safety on a PrivateObject in C#


Am I right that you want check presence of private method on .Net object?

Then pick one of the following cases to extract any method from instance:

Case 1 If you don’t care about method signature:

var typeOfObj = typeof(BancAccount)
               .GetMethods(
                 BindingFlags.NonPublic | 
                 BindingFlags.Instance)
               .Any( method => method.Name == testedName )

Case 2 If you need specify exact signature then use – typeof(BancAccount).GetMethod(testedName, <types of arguments>)

3

solved How to create type safety on a PrivateObject in C#