MethodBase.IsAbstract 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示此方法是否为抽象方法。
public:
 property bool IsAbstract { bool get(); };public bool IsAbstract { get; }member this.IsAbstract : boolPublic ReadOnly Property IsAbstract As Boolean属性值
如果该方法是抽象的,则为 true;否则为 false。
实现
示例
以下示例确定指定的 方法是否为抽象方法并显示结果。
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如果 或 构造函数不是公共构造函数,则它将受到保护,并且无法轻松访问。 若要访问非公共方法,请在 中GetMethod将BindingFlags掩码NonPublic设置为 。