C# MethodInfo GetParameters

Description

MethodInfo GetParameters When overridden in a derived class, gets the parameters of the specified method or constructor.

Syntax

MethodInfo.GetParameters has the following syntax.


public abstract ParameterInfo[] GetParameters()

Returns

MethodInfo.GetParameters method returns

Example


// w w  w.  j a  va  2  s  .  c  o  m
using System;
using System.Reflection;

public delegate void MyDelegate(int i);
public class MainClass 
{
    public event MyDelegate ev;

    public static void Main() 
    {
        Type delegateType = typeof(MainClass).GetEvent("ev").EventHandlerType;
        MethodInfo invoke = delegateType.GetMethod("Invoke");
        ParameterInfo[] pars = invoke.GetParameters();
        foreach (ParameterInfo p in pars) 
        {
            Console.WriteLine(p.ParameterType);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo