ParameterAttributes Enum
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Definierar de attribut som kan associeras med en parameter. Dessa definieras i CorHdr.h.
Den här uppräkningen stöder en bitvis kombination av dess medlemsvärden.
public enum class ParameterAttributes
[System.Flags]
public enum ParameterAttributes
[System.Flags]
[System.Serializable]
public enum ParameterAttributes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ParameterAttributes
[<System.Flags>]
type ParameterAttributes =
[<System.Flags>]
[<System.Serializable>]
type ParameterAttributes =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ParameterAttributes =
Public Enum ParameterAttributes
- Arv
- Attribut
Fält
| Name | Värde | Description |
|---|---|---|
| None | 0 | Anger att det inte finns något parameterattribut. |
| In | 1 | Anger att parametern är en indataparameter. |
| Out | 2 | Anger att parametern är en utdataparameter. |
| Lcid | 4 | Anger att parametern är en språkidentifierare (lcid). |
| Retval | 8 | Anger att parametern är ett returvärde. |
| Optional | 16 | Anger att parametern är valfri. |
| HasDefault | 4096 | Anger att parametern har ett standardvärde. |
| HasFieldMarshal | 8192 | Anger att parametern har fältmarskalkningsinformation. |
| Reserved3 | 16384 | Reserverat. |
| Reserved4 | 32768 | Reserverat. |
| ReservedMask | 61440 | Anger att parametern är reserverad. |
Exempel
I följande exempel visas attributen för den angivna parametern.
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
Kommentarer
ParameterAttributes Hämta värdet genom att Typeförst hämta . Hämta matrisen från TypeParameterInfo . Värdet ParameterAttributes finns i matrisen.
Dessa uppräkningsvärden är beroende av valfria metadata. Alla attribut är inte tillgängliga från alla kompilatorer. Se lämpliga kompilatorinstruktioner för att avgöra vilka uppräknade värden som är tillgängliga.