Gets a value indicating whether the Type is abstract and must be overridden.
Assembly: mscorlib (in mscorlib.dll)
Syntax . . :: . IsAbstract
Public ReadOnly Property IsAbstract As Booleanpublic bool IsAbstract { get; }public:
virtual property bool IsAbstract {
bool get () sealed;
}abstract IsAbstract : bool
override IsAbstract : boolImplements
_Type Remarks
If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false.
Examples
The following example returns true if the specified object is abstract; otherwise, it returns false.
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Public MustInherit Class MyMustInheritClass
End Class 'MyMustInheritClass
Public Class [MyClass]
End Class '[MyClass]
Public Class Type_IsMustInherit
Public Shared Sub Main()
Try
' Check whether the return type of MyMustInheritClass is MustInherit or not.
Console.WriteLine(ControlChars.NewLine + "Checking whether the type is MustInherit." + ControlChars.NewLine)
If GetType([MyMustInheritClass]).IsAbstract = True Then
Console.WriteLine("MyMustInheritClass is {0}", "a MustInherit class.")
Else
Console.WriteLine("MyMustInheritClass is {0}", "not a MustInherit class.")
End If
' Check whether the return type of MyClass is MustInherit or not.
If GetType([MyClass]).IsAbstract = True Then
Console.WriteLine("MyClass is {0}", "a MustInherit class.")
Else
Console.WriteLine("MyClass is {0}", "not a MustInherit class.")
End If
Catch e As Exception
Console.WriteLine("Exception: {0} " + ControlChars.Cr, e.Message.ToString())
End Try
End Sub 'Main
End Class 'Type_IsMustInherit
using System;
using System.Reflection;
public abstract class MyAbstractClass
{
}
public class MyClass
{
}
public class Type_IsAbstract
{
public static void Main()
{
try
{
// Check whether the return type of MyAbstractClass is abstract or not.
Console.WriteLine("\nChecking whether the type is abstract.\n");
Console.WriteLine("MyAbstractClass is {0}", (typeof(MyAbstractClass).IsAbstract) ? "an abstract class." : "not an abstract class.");
// Check whether the return type of MyClass is abstract or not.
Console.WriteLine("MyClass is {0}", (typeof(MyClass).IsAbstract) ? "an abstract class." : "not an abstract class.");
}
catch( Exception e )
{
Console.WriteLine( "Exception: {0} \n", e.Message );
}
}
}
using namespace System;
using namespace System::Reflection;
public ref class AbstractClass abstract
{
};
public ref class NonAbstractClass
{
};
int main()
{
// Check whether the return type of MyAbstractClass is abstract or not.
Console::WriteLine("\nChecking whether the type is abstract.\n");
if ((AbstractClass::typeid->IsAbstract))
{
Console::WriteLine("The AbstractClass is an abstract class.");
}
else
{
Console::WriteLine("The AbstractClass is not an abstract class.");
}
// Check whether the return type of MyClass is abstract or not.
if ((NonAbstractClass::typeid->IsAbstract))
{
Console::WriteLine("The NonAbstractClass is an abstract class.");
}
else
{
Console::WriteLine("The NonAbstractClass is not an abstract class.");
}
};
Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.