Get public method with the specified name in CSharp

Description

The following code shows how to get public method with the specified name.

Example


using System;//from w  w w .j  a  va2 s . co  m
using System.Reflection;

class Program
{
    public void MethodA() { }


    static void Main(string[] args)
    {
        MethodInfo mInfo = typeof(Program).GetMethod("MethodA");
        Console.WriteLine("Found method: {0}", mInfo);

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Reflection »




Array
Constructor
Event
Field
Interface
Method
Properties
Type