Invoking Methods by Using the MethodInfo Class
The Reflection API also provides the ability to search for and invoke methods that you may not have knowledge of at compile time. Before you can invoke a method, you must successfully request a MethodInfo object from the Type object. In this section we will investigate three ways to retrieve a MethodInfo from a Type object.
Working with the GetMethod Method
The easiest way to retrieve a MethodInfo object is to search for the method by name. The Type object provides the GetMethod(string methodName) to do just this. The string parameter contains the case-sensitive name of the public method to get. If you request a nonpublic method or a method that does not exist, then a null reference is returned. ...
Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.