ParameterInfo::Attributes Property

 

Gets the attributes for this parameter.

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

public:
property ParameterAttributes Attributes {
	virtual ParameterAttributes 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 namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public ref class MyClass1
{
public:
   int MyMethod( int i, [Out]short * j, long * k )
   {
       *j = 2;
      return 0;
   }

};

void main()
{
   // Get the type. 
   Type^ myType = MyClass1::typeid;

   // Get the method named 'MyMethod' from the type.
   MethodBase^ myMethodBase = myType->GetMethod( "MyMethod" );

   // Get the parameters associated with the method.
   array<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
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: