ParameterAttributes Enumeration
Defines the attributes that can be associated with a parameter. These are defined in CorHdr.h.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll)
| Member name | Description | |
|---|---|---|
![]() | None | Specifies that there is no parameter attribute. |
![]() | In | Specifies that the parameter is an input parameter. |
![]() | Out | Specifies that the parameter is an output parameter. |
![]() | Lcid | Specifies that the parameter is a locale identifier (lcid). |
![]() | Retval | Specifies that the parameter is a return value. |
![]() | Optional | Specifies that the parameter is optional. |
![]() | ReservedMask | Specifies that the parameter is reserved. |
![]() | HasDefault | Specifies that the parameter has a default value. |
![]() | HasFieldMarshal | Specifies that the parameter has field marshaling information. |
![]() | Reserved3 | Reserved. |
![]() | Reserved4 | Reserved. |
To get the ParameterAttributes value, first get the Type. From the Type, get the ParameterInfo array. The ParameterAttributes value is within the array.
These enumerator values are dependent on optional metadata. Not all attributes are available from all compilers. See the appropriate compiler instructions to determine which enumerated values are available.
The following example displays the attributes of the specified parameter.
using namespace System; using namespace System::Reflection; using namespace System::Runtime::InteropServices; public ref class paramatt { public: static void mymethod( String^ str1, [Out]interior_ptr<String^> str2, interior_ptr<String^> str3 ) { *str2 = "string"; } }; int main() { Console::WriteLine( "\nReflection.ParameterAttributes" ); // Get the Type and the method. Type^ Mytype = Type::GetType( "paramatt" ); MethodBase^ Mymethodbase = Mytype->GetMethod( "mymethod" ); // Display the method. Console::Write( "\nMymethodbase = {0}", Mymethodbase ); // Get the ParameterInfo array. array<ParameterInfo^>^Myarray = Mymethodbase->GetParameters(); // Get and display the attributes for the second parameter. ParameterAttributes Myparamattributes = Myarray[ 1 ]->Attributes; Console::Write( "\nFor the second parameter:\nMyparamattributes = {0}, which is an {1}", (int)Myparamattributes, Myparamattributes ); return 0; }
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.
