다음을 통해 공유


MethodAttributes 열거형

메서드 특성에 대한 플래그를 지정합니다. 이러한 플래그는 corhdr.h 파일에 정의됩니다.

이 열거형에는 멤버 값를 비트로 조합할 수 있는 FlagsAttribute 특성이 있습니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration MethodAttributes
‘사용 방법
Dim instance As MethodAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum MethodAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum class MethodAttributes
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum MethodAttributes
SerializableAttribute 
FlagsAttribute 
ComVisibleAttribute(true) 
public enum MethodAttributes

멤버

  멤버 이름 설명
Supported by the .NET Compact Framework Abstract 클래스에서 이 메서드를 구현하지 않습니다. 
Supported by the .NET Compact Framework Assembly 이 어셈블리의 모든 클래스에서 메서드에 액세스할 수 있습니다. 
CheckAccessOnOverride 메서드에 액세스할 수 있을 때만 메서드를 재정의할 수 있음을 나타냅니다. 
Supported by the .NET Compact Framework FamANDAssem 이 형식 및 이 어셈블리에 있는 파생 형식의 멤버만 메서드에 액세스할 수 있음을 나타냅니다. 
Supported by the .NET Compact Framework Family 이 클래스 및 파생 클래스의 멤버만 메서드에 액세스할 수 있습니다. 
Supported by the .NET Compact Framework FamORAssem 파생 클래스뿐만 아니라 어셈블리에 있는 모든 클래스가 메서드에 액세스할 수 있음을 나타냅니다. 
Supported by the .NET Compact Framework Final 메서드를 재정의할 수 없음을 나타냅니다. 
Supported by the .NET Compact Framework HasSecurity 메서드에 이와 관련된 보안이 있습니다. 런타임 전용의 예약된 플래그입니다. 
Supported by the .NET Compact Framework HideBySig 메서드를 이름 및 서명별로 숨깁니다. 그렇지 않으면 이름별로만 숨깁니다. 
Supported by the .NET Compact Framework MemberAccessMask 액세스 가능성 정보를 검색합니다. 
Supported by the .NET Compact Framework NewSlot 메서드가 항상 vtable에 새 슬롯을 가져옵니다. 
Supported by the .NET Compact Framework PinvokeImpl 메서드 구현이 PInvoke(Platform Invocation Services)를 통해 전달됩니다. 
Supported by the .NET Compact Framework Private 현재 클래스만 메서드에 액세스할 수 있음을 나타냅니다. 
Supported by the .NET Compact Framework PrivateScope 멤버를 참조할 수 없습니다. 
Supported by the .NET Compact Framework Public 이 개체 범위 내의 개체만 메서드에 액세스할 수 있습니다. 
Supported by the .NET Compact Framework RequireSecObject 메서드가 보안 코드를 포함하는 다른 메서드를 호출합니다. 런타임 전용의 예약된 플래그입니다. 
Supported by the .NET Compact Framework ReservedMask 런타임 전용의 예약된 플래그를 나타냅니다. 
Supported by the .NET Compact Framework ReuseSlot 메서드에서 vtable의 기존 슬롯을 다시 사용합니다. 이것은 기본적인 동작입니다. 
Supported by the .NET Compact Framework RTSpecialName 공용 언어 런타임에서 이름 인코딩을 확인합니다. 
Supported by the .NET Compact Framework SpecialName 특수한 메서드입니다. 메서드의 이름은 이 메서드가 특수함을 나타냅니다. 
Supported by the .NET Compact Framework Static 메서드가 형식에 정의되어 있습니다. 그렇지 않으면 인스턴스 단위로 정의됩니다. 
Supported by the .NET Compact Framework UnmanagedExport 썽크에서 관리되는 메서드를 비관리 코드로 보냅니다. 
Supported by the .NET Compact Framework Virtual 가상 메서드입니다. 
Supported by the .NET Compact Framework VtableLayoutMask vtable 특성을 검색합니다. 

예제

다음 예제에서는 지정된 메서드의 특성을 표시합니다.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Class AttributesSample

    Public Sub Mymethod(ByVal int1m As Integer, ByRef str2m As String, ByRef str3m As String)
        str2m = "in Mymethod"
    End Sub 'Mymethod


    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 'PrintAttributes
End Class 'AttributesSample
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);
            }
        }
    }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

public ref class AttributesSample
{
public:
   void Mymethod( int int1m, [Out]interior_ptr<String^> str2m, interior_ptr<String^> str3m )
   {
       *str2m = "in Mymethod";
   }
};

void PrintAttributes( Type^ attribType, int iAttribValue )
{
   if (  !attribType->IsEnum )
   {
      Console::WriteLine( "This type is not an enum." );
      return;
   }

   array<FieldInfo^>^fields = attribType->GetFields( static_cast<BindingFlags>(BindingFlags::Public | BindingFlags::Static) );
   for ( int i = 0; i < fields->Length; i++ )
   {
      int fieldvalue = safe_cast<Int32>(fields[ i ]->GetValue( nullptr ));
      if ( (fieldvalue & iAttribValue) == fieldvalue )
      {
         Console::WriteLine( fields[ i ]->Name );
      }
   }
}

int main()
{
   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 = {0}", Mymethodbase );

   // Get the MethodAttribute enumerated value.
   MethodAttributes Myattributes = Mymethodbase->Attributes;

   // Display the flags that are set.
   PrintAttributes( System::Reflection::MethodAttributes::typeid, (int)Myattributes );
   return 0;
}
import System.*;
import System.Reflection.*;

class AttributesSample
{   
    public void MyMethod(int int1m,
        /** @ref
         */ String str2m,
        /** @ref
         */ String str3m)
    {
        str2m = "in MyMethod";
    } //MyMethod

    public static void 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.get_Attributes();

        // Display the flags that are set.
        PrintAttributes(System.Reflection.MethodAttributes.class.ToType(),
            (int)(myAttributes));
    } //main

    public static void PrintAttributes(Type attribType, int iAttribValue)
    {
        if (!(attribType.get_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)((Int32)(fields[i].GetValue(null)));
            if ((fieldValue & iAttribValue) == fieldValue  ) {
                Console.WriteLine(fields[i].get_Name());
            }
        } 
    } //PrintAttributes
} //AttributesSample

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

System.Reflection 네임스페이스