Export (0) Print
Expand All
Expand Minimize

Type::IsSubclassOf Method

Determines whether the current Type derives from the specified Type.

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

[ComVisibleAttribute(true)]
public:
virtual bool IsSubclassOf(
	Type^ c
)

Parameters

c
Type: System::Type

The type to compare with the current type.

Return Value

Type: System::Boolean
true if the current Type derives from c; otherwise, false. This method also returns false if c and the current Type are equal.

Implements

_Type::IsSubclassOf(Type)

ExceptionCondition
ArgumentNullException

c is nullptr.

You can call the IsSubclassOf method to determine any of the following:

  • Whether one class derives from another.

  • Whether a type derives from ValueType. However, the IsValueType is a more efficient way to determine whether a type is a value type.

  • Whether a type derives from Enum. However, the IsEnum method is a more efficient way to determine whether a type is an enumeration.

  • Whether a type is a delegate, that is, whether it derives from either Delegate or MulticastDelegate.

The IsSubclassOf method cannot be used to determine whether an interface derives from another interface, or whether a class implements an interface. Use the IsAssignableFrom method for that purpose, as the following example shows.

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

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

Except when used with interfaces, 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 creates a class named Class1 and a derived class named DerivedC1. It calls the IsSubclassOf method to show that DerivedC1 is a subclass of Class1.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft