|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
MethodAttributes, énumération
.NET Framework 4.5
Cette énumération possède un attribut FlagsAttribute qui permet la combinaison d'opérations de bits de ses valeurs de membres.
Espace de noms : System.Reflection
Assembly : mscorlib (dans mscorlib.dll)
| Nom de membre | Description | |
|---|---|---|
![]() ![]() ![]() | 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 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.


