Retrieves public methods for a class. - CSharp System.Reflection

CSharp examples for System.Reflection:MethodInfo

Description

Retrieves public methods for a class.

Demo Code


using System.Text;
using System.Reflection;
using System.Collections.Generic;
using System.Collections;
using System;//from   w  ww .  j a va 2 s. c  om

public class Main{
        /// <summary>
      /// Retrieves public methods for a class.
      /// </summary>
      private static MethodInfo[] GetAccessibleMethods(Type clazz)
      {
         ArrayList methods = new ArrayList();

         foreach(Type iface in clazz.GetInterfaces())
         {
            methods.AddRange(iface.GetMethods());
         }

         methods.AddRange(clazz.GetMethods());

         return (MethodInfo[]) methods.ToArray(typeof(MethodInfo));
      }
}

Related Tutorials