MethodBase.IsAbstract Property

Gets a value indicating whether the method is abstract.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public bool IsAbstract { get; }

Property Value

Type: System.Boolean
true if the method is abstract; otherwise, false.

An abstract member is declared on a base class and has no implementation supplied.

To get the MethodBase, first get the type. From the type, get the method. From the method, get the MethodBase. If the MethodBase or constructor is other than public, it is protected and cannot be readily accessed. To access a non-public method, set the BindingFlags mask to NonPublic in GetMethod.

The following example determines whether specified the method is abstract and displays the result.

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;
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft