Type.IsAbstract Property

May 11, 2014

Gets a value indicating whether the Type is abstract and must be overridden.

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

public bool IsAbstract { get; }

Property Value

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

If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false.

The following example returns true if the specified object is abstract; otherwise, it returns false.



using System;
using System.Reflection;
public abstract class MyAbstractClass
{
}
public class MyClass
{
}
public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      try
      {
         // Check whether the return type of MyAbstractClass is abstract or not.
         outputBlock.Text += "\nChecking whether the type is abstract.\n" + "\n";
         outputBlock.Text += String.Format("MyAbstractClass is {0}", (typeof(MyAbstractClass).IsAbstract) ? "an abstract class." : "not an abstract class.") + "\n";
         // Check whether the return type of MyClass is abstract or not.
         outputBlock.Text += String.Format("MyClass is {0}", (typeof(MyClass).IsAbstract) ? "an abstract class." : "not an abstract class.") + "\n";
      }
      catch (Exception e)
      {
         outputBlock.Text += String.Format("Exception: {0} \n", e.Message) + "\n";
      }
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft