C# Type GetMethods()
Description
Type GetMethods()
returns all the public methods of the
current Type.
Syntax
Type.GetMethods()
has the following syntax.
public MethodInfo[] GetMethods()
Returns
Type.GetMethods()
method returns
Example
using System;/*w w w.j a v a 2s.co m*/
using System.Reflection;
using System.Reflection.Emit;
public class MyTypeClass
{
public void MyMethods()
{
}
public int MyMethods1()
{
return 3;
}
protected String MyMethods2()
{
return "hello";
}
}
public class TypeMain
{
public static void Main()
{
Type myType =(typeof(MyTypeClass));
MethodInfo[] myArrayMethodInfo = myType.GetMethods();
Console.WriteLine(myArrayMethodInfo.Length);
}
}
The code above generates the following result.