다음을 통해 공유


MethodBase.IsAbstract 속성

정의

이 메서드가 추상 메서드인지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsAbstract { bool get(); };
public bool IsAbstract { get; }
member this.IsAbstract : bool
Public ReadOnly Property IsAbstract As Boolean

속성 값

해당 메서드가 추상 메서드이면 true이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는 지정된 메서드가 추상인지 여부를 확인하고 결과를 표시합니다.

using namespace System;
using namespace System::Reflection;
int main()
{
   Console::WriteLine( "\nReflection.MethodBase" );
   
   // Get the types.
   Type^ MyType1 = Type::GetType( "System.Runtime.Serialization.Formatter" );
   Type^ MyType2 = Type::GetType( "System.Reflection.MethodBase" );
   
   // Get and display the methods.
   MethodBase^ Mymethodbase1 = MyType1->GetMethod( "WriteInt32", static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Instance) );
   MethodBase^ Mymethodbase2 = MyType2->GetMethod( "GetCurrentMethod", static_cast<BindingFlags>(BindingFlags::Public | BindingFlags::Static) );
   Console::Write( "\nMymethodbase = {0}", Mymethodbase1 );
   if ( Mymethodbase1->IsAbstract )
      Console::Write( "\nMymethodbase is an abstract method." );
   else
      Console::Write( "\nMymethodbase is not an abstract method." );

   Console::Write( "\n\nMymethodbase = {0}", Mymethodbase2 );
   if ( Mymethodbase2->IsAbstract )
      Console::Write( "\nMymethodbase is an abstract method." );
   else
      Console::Write( "\nMymethodbase is not an abstract method." );

   return 0;
}
using System;
using System.Reflection;
// using System.Windows.Forms;

class methodbase
{
    public static int Main(string[] args)
    {
        Console.WriteLine ("\nReflection.MethodBase");

        // Get the types.
        Type MyType1 = Type.GetType("System.Runtime.Serialization.Formatter");
        Type MyType2 = Type.GetType("System.Reflection.MethodBase");

        // Get and display the methods.
        MethodBase Mymethodbase1 =
            MyType1.GetMethod("WriteInt32", BindingFlags.NonPublic|BindingFlags.Instance);

        MethodBase Mymethodbase2 =
            MyType2.GetMethod("GetCurrentMethod", BindingFlags.Public|BindingFlags.Static);

        Console.Write("\nMymethodbase = " + Mymethodbase1.ToString());
        if (Mymethodbase1.IsAbstract)
            Console.Write ("\nMymethodbase is an abstract method.");
        else
            Console.Write ("\nMymethodbase is not an abstract method.");

        Console.Write("\n\nMymethodbase = " + Mymethodbase2.ToString());
        if (Mymethodbase2.IsAbstract)
            Console.Write ("\nMymethodbase is an abstract method.");
        else
            Console.Write ("\nMymethodbase is not an abstract method.");

        return 0;
    }
}
Imports System.Reflection

Class methodbase1

    Public Shared Function Main() As Integer
        Console.WriteLine("Reflection.MethodBase")
        Console.WriteLine()
        ' Get the types.
        Dim MyType1 As Type = _
           Type.GetType("System.Runtime.Serialization.Formatter")
        Dim MyType2 As Type = _
           Type.GetType("System.Reflection.MethodBase")

        ' Get and display the methods
        Dim Mymethodbase1 As MethodBase = _
           MyType1.GetMethod("WriteInt32", BindingFlags.NonPublic Or BindingFlags.Instance)
        Dim Mymethodbase2 As MethodBase = _
           MyType2.GetMethod("GetCurrentMethod", BindingFlags.Public Or BindingFlags.Static)

        Console.WriteLine("Mymethodbase = {0}", Mymethodbase1.ToString())
        If Mymethodbase1.IsAbstract Then
            Console.WriteLine(ControlChars.CrLf & "Mymethodbase is an abstract method.")
        Else
            Console.WriteLine(ControlChars.CrLf & "Mymethodbase is not an abstract method.")
        End If
        Console.Write("Mymethodbase = {0}", Mymethodbase2.ToString())
        If Mymethodbase2.IsAbstract Then
            Console.WriteLine(ControlChars.CrLf & "Mymethodbase is an abstract method.")
        Else
            Console.WriteLine(ControlChars.CrLf & "Mymethodbase is not an abstract method.")
        End If
        Return 0
    End Function

End Class

설명

추상 멤버는 기본 클래스에 선언되며 제공된 구현이 없습니다.

MethodBase얻으려면 먼저 형식을 가져옵니다. 형식에서 메서드를 가져옵니다. 메서드에서 를 가져옵니다 MethodBase. MethodBase 또는 생성자가 public이 아닌 경우 보호되며 쉽게 액세스할 수 없습니다. public이 아닌 메서드에 액세스하려면 에서 마스크를 BindingFlagsNonPublicGetMethod설정합니다.

적용 대상

추가 정보