MethodAttributes Sabit listesi
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Yöntem öznitelikleri için bayrakları belirtir. Bu bayraklar corhdr.h dosyasında tanımlanır.
Bu sabit listesi, üyeleri için bit düzeyinde karşılaştırmayı destekler.
public enum class MethodAttributes
[System.Flags]
public enum MethodAttributes
[System.Flags]
[System.Serializable]
public enum MethodAttributes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodAttributes
[<System.Flags>]
type MethodAttributes =
[<System.Flags>]
[<System.Serializable>]
type MethodAttributes =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MethodAttributes =
Public Enum MethodAttributes
- Devralma
- Öznitelikler
Alanlar
| Name | Değer | Description |
|---|---|---|
| PrivateScope | 0 | Üyeye başvurulamadığını gösterir. |
| ReuseSlot | 0 | yönteminin vtable'da var olan bir yuvayı yeniden kullanacağını gösterir. Bu varsayılan davranıştır. |
| Private | 1 | Yönteminin yalnızca geçerli sınıf için erişilebilir olduğunu gösterir. |
| FamANDAssem | 2 | Yöntemin bu türün üyeleri ve yalnızca bu derlemede bulunan türetilmiş türleri için erişilebilir olduğunu gösterir. |
| Assembly | 3 | Yöntemin bu derlemenin herhangi bir sınıfı için erişilebilir olduğunu gösterir. |
| Family | 4 | yönteminin yalnızca bu sınıfın üyeleri ve türetilmiş sınıfları için erişilebilir olduğunu gösterir. |
| FamORAssem | 5 | Yöntemin her yerde türetilmiş sınıflar ve derlemedeki herhangi bir sınıf için erişilebilir olduğunu gösterir. |
| Public | 6 | Yöntemin, bu nesnenin kapsamında olduğu herhangi bir nesne için erişilebilir olduğunu gösterir. |
| MemberAccessMask | 7 | Erişilebilirlik bilgilerini alır. |
| UnmanagedExport | 8 | Yönetilen yöntemin yönetilmeyen koda thunk tarafından dışarı aktarıldığını gösterir. |
| Static | 16 | yönteminin türünde tanımlandığını gösterir; aksi takdirde, örnek başına tanımlanır. |
| Final | 32 | Yöntemin geçersiz kılınamayacağını gösterir. |
| Virtual | 64 | Yönteminin sanal olduğunu gösterir. |
| HideBySig | 128 | yönteminin ada ve imzaya göre gizlendiğini gösterir; aksi takdirde, yalnızca ada göre. |
| NewSlot | 256 | Yöntemin her zaman vtable'da yeni bir yuva aldığını gösterir. |
| VtableLayoutMask | 256 | Vtable özniteliklerini alır. |
| CheckAccessOnOverride | 512 | Yöntemin yalnızca erişilebilir olduğunda geçersiz kılınabileceğini gösterir. |
| Abstract | 1024 | sınıfının bu yöntemin bir uygulamasını sağlamadığını gösterir. |
| SpecialName | 2048 | Yönteminin özel olduğunu gösterir. Ad, bu yöntemin nasıl özel olduğunu açıklar. |
| RTSpecialName | 4096 | Ortak dil çalışma zamanının ad kodlamasını denetlediğini gösterir. |
| PinvokeImpl | 8192 | Yöntem uygulamasının PInvoke (Platform Çağırma Hizmetleri) aracılığıyla iletildiğini gösterir. |
| HasSecurity | 16384 | Yöntemin kendisiyle ilişkilendirilmiş güvenliği olduğunu gösterir. Yalnızca çalışma zamanı kullanımı için ayrılmış bayrak. |
| RequireSecObject | 32768 | yönteminin güvenlik kodu içeren başka bir yöntemi çağırdığını gösterir. Yalnızca çalışma zamanı kullanımı için ayrılmış bayrak. |
| ReservedMask | 53248 | Yalnızca çalışma zamanı kullanımı için ayrılmış bayrağı gösterir. |
Örnekler
Aşağıdaki örnek, belirtilen yöntemin özniteliklerini görüntüler.
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 = (int)fields[i].GetValue(null);
if ((fieldvalue & iAttribValue) == fieldvalue)
{
Console.WriteLine(fields[i].Name);
}
}
}
}
Imports System.Reflection
Class AttributesSample
Public Sub Mymethod(ByVal int1m As Integer, ByRef str2m As String, ByRef str3m As String)
str2m = "in Mymethod"
End Sub
Public Shared Function Main(ByVal args() As String) As Integer
Console.WriteLine("Reflection.MethodBase.Attributes Sample")
' Get the type of a chosen class.
Dim MyType As Type = Type.GetType("AttributesSample")
' Get the method Mymethod on the type.
Dim Mymethodbase As MethodBase = MyType.GetMethod("Mymethod")
' Display the method name and signature.
Console.WriteLine("Mymethodbase = {0}", Mymethodbase)
' Get the MethodAttribute enumerated value.
Dim Myattributes As MethodAttributes = Mymethodbase.Attributes
' Display the flags that are set.
PrintAttributes(GetType(System.Reflection.MethodAttributes), CInt(Myattributes))
Return 0
End Function 'Main
Public Shared Sub PrintAttributes(ByVal attribType As Type, ByVal iAttribValue As Integer)
If Not attribType.IsEnum Then
Console.WriteLine("This type is not an enum.")
Return
End If
Dim fields As FieldInfo() = attribType.GetFields((BindingFlags.Public Or BindingFlags.Static))
Dim i As Integer
For i = 0 To fields.Length - 1
Dim fieldvalue As Integer = CType(fields(i).GetValue(Nothing), Int32)
If (fieldvalue And iAttribValue) = fieldvalue Then
Console.WriteLine(fields(i).Name)
End If
Next i
End Sub
End Class