Get all methods from a Type : Type : Reflection C# Examples


C# Examples » Reflection » Type »

 

Get all methods from a Type









    
using  System;
using  System.Reflection;

class  MyClass
{
      public  int  Field1;
      public  int  Field2;
      public  void  Method1()  {  }
      public  int    Method2()  {  return  1;  }
}

class  MainClass
{
      static  void  Main()
      {
            Type  t  =  typeof(MyClass);
            MethodInfo[]  mi  =  t.GetMethods();

            foreach  (MethodInfo  m  in  mi)
                  Console.WriteLine("Method:  {0}",  m.Name);

      }
}
    
   
  
   



Output

Method: Method1
Method: Method2
Method: GetType
Method: ToString
Method: Equals
Method: GetHashCode


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Reflection
» Type