This documentation is archived and is not being maintained.

ParameterInfo.Attributes Property

Gets the attributes for this parameter.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public virtual ParameterAttributes Attributes { get; }

Property Value

Type: System.Reflection.ParameterAttributes
A ParameterAttributes object representing the attributes for this parameter.

This method utilizes the AttrsImpl method.

To get the ParameterInfo array, first get the method or the constructor and then call MethodBase.GetParameters.

The following example defines a method with three parameters. It uses the Attributes property to get the attributes of the second parameter and display them at the console.

using System;
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()
      // Get the type. 
      Type myType = typeof(MyClass1);
      // Get the method named 'MyMethod' from the type.
      MethodBase myMethodBase = myType.GetMethod("MyMethod");
      // Get the parameters associated with the method.
      ParameterInfo[] myParameters = myMethodBase.GetParameters();
      Console.WriteLine("\nThe method {0} has the {1} parameters :", 
                          "ParameterInfo_Example.MyMethod", myParameters.Length);
      // Print the attributes associated with each of the parameters.
      for(int i = 0; i < myParameters.Length; i++)
         Console.WriteLine("\tThe {0} parameter has the attribute : {1}", 
                                             i + 1, myParameters[i].Attributes);

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.