|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Enumerazione MethodAttributes
.NET Framework 4.5
Questa enumerazione dispone di un attributo FlagsAttribute che consente una combinazione bit per bit dei valori dei membri.
Spazio dei nomi: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
| Nome membro | Descrizione | |
|---|---|---|
![]() ![]() ![]() | MemberAccessMask | |
![]() ![]() ![]() | PrivateScope | |
![]() ![]() ![]() | Private | |
![]() ![]() ![]() | FamANDAssem | |
![]() ![]() ![]() | Assembly | |
![]() ![]() ![]() | Family | |
![]() ![]() ![]() | FamORAssem | |
![]() ![]() ![]() | Public | |
![]() ![]() ![]() | Static | |
![]() ![]() ![]() | Final | |
![]() ![]() ![]() | Virtual | |
![]() ![]() ![]() | HideBySig | |
![]() ![]() | CheckAccessOnOverride | |
![]() ![]() | VtableLayoutMask | |
![]() ![]() ![]() | ReuseSlot | |
![]() ![]() ![]() | NewSlot | |
![]() ![]() ![]() | Abstract | |
![]() ![]() ![]() | SpecialName | |
![]() ![]() ![]() | PinvokeImpl | |
![]() ![]() ![]() | UnmanagedExport | |
![]() ![]() ![]() | RTSpecialName | |
![]() | ReservedMask | |
![]() ![]() ![]() | HasSecurity | |
![]() ![]() ![]() | RequireSecObject |
using System; using System.Reflection; class AttributesSample { public void Mymethod (int int1m, out string str2m, ref string str3m) { str2m = "in Mymethod"; } public static int Main(string[] args) { Console.WriteLine ("Reflection.MethodBase.Attributes Sample"); // Get the type of the chosen class. Type MyType = Type.GetType("AttributesSample"); // Get the method Mymethod on the type. MethodBase Mymethodbase = MyType.GetMethod("Mymethod"); // Display the method name and signature. Console.WriteLine("Mymethodbase = " + Mymethodbase); // Get the MethodAttribute enumerated value. MethodAttributes Myattributes = Mymethodbase.Attributes; // Display the flags that are set. PrintAttributes(typeof(System.Reflection.MethodAttributes), (int) Myattributes); return 0; } public static void PrintAttributes(Type attribType, int iAttribValue) { if (!attribType.IsEnum) {Console.WriteLine("This type is not an enum."); return;} FieldInfo[] fields = attribType.GetFields(BindingFlags.Public | BindingFlags.Static); for (int i = 0; i < fields.Length; i++) { int fieldvalue = (Int32)fields[i].GetValue(null); if ((fieldvalue & iAttribValue) == fieldvalue) { Console.WriteLine(fields[i].Name); } } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.


