Export (0) Print
Expand All
Expand Minimize

Type.IsSubclassOf Method

Determines whether the class represented by the current Type derives from the class represented by the specified Type.

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

[<ComVisibleAttribute(true)>]
abstract IsSubclassOf : 
        c:Type -> bool 
[<ComVisibleAttribute(true)>]
override IsSubclassOf : 
        c:Type -> bool

Parameters

c
Type: System.Type

The type to compare with the current type.

Return Value

Type: System.Boolean
true if the Type represented by the c parameter and the current Type represent classes, and the class represented by the current Type derives from the class represented by c; otherwise, false. This method also returns false if c and the current Type represent the same class.

Implements

_Type.IsSubclassOf(Type)

ExceptionCondition
ArgumentNullException

The c parameter is a null reference (Nothing in Visual Basic).

The IsSubclassOf method cannot be used to determine whether an interface derives from another interface, or whether a class implements an interface. Use the GetInterface method for that purpose. Note that if a type is dervived from an interface, this method returns true for that type being a subclass of Object.

If the current Type represents a type parameter in the definition of a generic type or generic method, it derives from its class constraint or from System.Object if it has no class constraint.

NoteNote

If the IsSubclassOf is the converse of IsAssignableFrom. That is, if t1.IsSubclassOf(t2) is true, then t2.IsAssignableFrom(t1) is also true.

This method can be overridden by a derived class.

The following example demonstrates the use of the IsSubclassOf method by creating an instance of a class and an instance of its derived class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 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 Phone apps

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

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.

Show:
© 2014 Microsoft