ParameterInfo.Attributes Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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);

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top