ParameterAttributes Enumerazione
In questo articolo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Definisce gli attributi che è possibile associare a un parametro. Questi attributi sono definiti nel file CorHdr.h.
Questa enumerazione supporta una combinazione bit per bit dei rispettivi valori dei membri.
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
- Ereditarietà
- Attributi
Nome | Valore | Descrizione |
---|---|---|
HasDefault | 4096 | Specifica che il parametro ha un valore predefinito. |
HasFieldMarshal | 8192 | Specifica che il parametro dispone di informazioni di marshalling del campo. |
In | 1 | Specifica che si tratta di un parametro di input. |
Lcid | 4 | Specifica che il parametro è un identificatore di impostazioni locali (lcid). |
None | 0 | Specifica che non esiste alcun attributo di parametro. |
Optional | 16 | Specifica che si tratta di un parametro opzionale. |
Out | 2 | Specifica che si tratta di un parametro di output. |
Reserved3 | 16384 | Riservato. |
Reserved4 | 32768 | Riservato. |
ReservedMask | 61440 | Specifica che si tratta di un parametro riservato. |
Retval | 8 | Specifica che il parametro è un valore restituito. |
Nell'esempio seguente vengono visualizzati gli attributi del parametro specificato.
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
Per ottenere il ParameterAttributes
valore, ottenere prima di tutto .Type
Dall'oggetto Type
, ottenere la ParameterInfo
matrice. Il ParameterAttributes
valore si trova all'interno della matrice.
Questi valori dell'enumeratore dipendono dai metadati facoltativi. Non tutti gli attributi sono disponibili da tutti i compilatori. Per determinare quali valori enumerati sono disponibili, vedere le istruzioni appropriate del compilatore.
Prodotto | Versioni |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: