ParameterAttributes Enumeration
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll)
'Declaration <SerializableAttribute> _ <FlagsAttribute> _ <ComVisibleAttribute(True)> _ Public Enumeration ParameterAttributes 'Usage Dim instance As ParameterAttributes
/** @attribute SerializableAttribute() */ /** @attribute FlagsAttribute() */ /** @attribute ComVisibleAttribute(true) */ public enum ParameterAttributes
SerializableAttribute FlagsAttribute ComVisibleAttribute(true) public enum ParameterAttributes
| Member name | Description | |
|---|---|---|
![]() | HasDefault | Specifies that the parameter has a default value. |
![]() | HasFieldMarshal | Specifies that the parameter has field marshaling information. |
![]() | In | Specifies that the parameter is an input parameter. |
![]() | Lcid | Specifies that the parameter is a locale identifier (lcid). |
![]() | None | Specifies that there is no parameter attribute. |
![]() | Optional | Specifies that the parameter is optional. |
![]() | Out | Specifies that the parameter is an output parameter. |
![]() | Reserved3 | Reserved. |
![]() | Reserved4 | Reserved. |
![]() | ReservedMask | Specifies that the parameter is reserved. |
![]() | Retval | Specifies that the parameter is a return value. |
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.
Imports System Imports System.Reflection Imports Microsoft.VisualBasic Class paramatt Public Shared Sub mymethod(ByVal str1 As String, ByRef str2 As String, _ ByRef str3 As String) str2 = "string" End Sub Public Shared Function Main() As Integer Console.WriteLine(ControlChars.CrLf + "Reflection.ParameterAttributes") ' Get the Type and the method. Dim Mytype As Type = Type.GetType("paramatt") Dim Mymethodbase As MethodBase = Mytype.GetMethod("mymethod") ' Display the method. Console.WriteLine("Mymethodbase = " + Mymethodbase.ToString()) ' Get the ParameterInfo array. Dim Myarray As ParameterInfo() = Mymethodbase.GetParameters() ' Get and display the attributes for the second parameter. Dim Myparamattributes As ParameterAttributes = Myarray(1).Attributes Console.WriteLine("For the second parameter:" + ControlChars.CrLf _ + "Myparamattributes = " + CInt(Myparamattributes).ToString() _ + ", which is a " + Myparamattributes.ToString()) Return 0 End Function End Class
import System.*;
import System.Reflection.*;
class Paramatt
{
public static void Mymethod(String str1,
/** @ref
*/ String str2,
/** @ref
*/ String str3)
{
str2 = "string";
} //Mymethod
public static void main(String[] args)
{
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 = " + myMethodBase));
// Get the ParameterInfo array.
ParameterInfo myArray[] = myMethodBase.GetParameters();
// Get and display the attributes for the second parameter.
ParameterAttributes myParamAttributes = myArray[1].get_Attributes();
Console.Write(("\nFor the second parameter:\nMyparamattributes = "
+ (int)(myParamAttributes) + ", which is an "
+ myParamAttributes.ToString()));
} //main
} //Paramatt
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.