ParameterAttributes Enumeration
Definition
Definiert die Attribute, die einem Parameter zugeordnet werden können.Defines the attributes that can be associated with a parameter. Diese sind in CorHdr.h definiert.These are defined in CorHdr.h.
Diese Enumeration weist ein FlagsAttribute-Attribut auf, die eine bitweise Kombination der Memberwerte zulässt.
public enum class ParameterAttributes
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum ParameterAttributes
type ParameterAttributes =
Public Enum ParameterAttributes
- Vererbung
- Attribute
Felder
HasDefault | 4096 | Gibt an, dass der Parameter einen Standardwert besitzt.Specifies that the parameter has a default value. |
HasFieldMarshal | 8192 | Gibt an, dass der Parameter über Marshallinginformationen für Felder verfügt.Specifies that the parameter has field marshaling information. |
In | 1 | Gibt an, dass der Parameter ein Eingabeparameter ist.Specifies that the parameter is an input parameter. |
Lcid | 4 | Gibt an, dass der Parameter ein Gebietsschemabezeichner (lcid) ist.Specifies that the parameter is a locale identifier (lcid). |
None | 0 | Gibt an, dass kein Parameterattribut vorhanden ist.Specifies that there is no parameter attribute. |
Optional | 16 | Gibt an, dass der Parameter optional ist.Specifies that the parameter is optional. |
Out | 2 | Gibt an, dass der Parameter ein Ausgabeparameter ist.Specifies that the parameter is an output parameter. |
Reserved3 | 16384 | Reserviert.Reserved. |
Reserved4 | 32768 | Reserviert.Reserved. |
ReservedMask | 61440 | Gibt an, dass der Parameter reserviert ist.Specifies that the parameter is reserved. |
Retval | 8 | Gibt an, dass der Parameter ein Rückgabewert ist.Specifies that the parameter is a return value. |
Beispiele
Im folgenden Beispiel werden die Attribute des angegebenen Parameters angezeigt.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;
}
using System;
using System.Reflection;
class paramatt
{
public static void mymethod (string str1, out string str2, ref string str3)
{
str2 = "string";
}
public static int 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].Attributes;
Console.Write("\nFor the second parameter:\nMyparamattributes = "
+ (int) Myparamattributes
+ ", which is an "
+ Myparamattributes.ToString());
return 0;
}
}
Imports System.Reflection
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
Hinweise
Um den ParameterAttributes
Wert zu erhalten, erhalten Sie Type
zuerst die.To get the ParameterAttributes
value, first get the Type
. Im können Sie das ParameterInfo
Array erhalten. Type
From the Type
, get the ParameterInfo
array. Der ParameterAttributes
Wert liegt innerhalb des Arrays.The ParameterAttributes
value is within the array.
Diese Enumeratorwerte sind von optionalen Metadaten abhängig.These enumerator values are dependent on optional metadata. Nicht alle Attribute sind für alle Compiler verfügbar.Not all attributes are available from all compilers. Sehen Sie sich die entsprechenden Compileranweisungen an, um zu bestimmen, welche aufgelisteten Werte verfügbar sind.See the appropriate compiler instructions to determine which enumerated values are available.