C# ParameterInfo Attributes

Description

ParameterInfo Attributes Gets the attributes for this parameter.

Syntax

ParameterInfo.Attributes has the following syntax.


public virtual ParameterAttributes Attributes { get; }

Example


using System;// w  w  w  .  j a  v a 2s .  c  o m
using System.Reflection;
public class MyClass1
{
   public int MyMethod( int i, out short j, ref long k)
   {
      j = 2;
      return 0;
   }  
}

public class ParameterInfo_Attributes
{   
   public static void Main()
   {
      Type myType = typeof(MyClass1);
      MethodBase myMethodBase = myType.GetMethod("MyMethod");
      ParameterInfo[] myParameters = myMethodBase.GetParameters();
      for(int i = 0; i < myParameters.Length; i++)
         Console.WriteLine(myParameters[i].Attributes);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo