Skip to main content
.NET Framework Class Library
Type..::.BaseType Property

Gets the type from which the current Type directly inherits.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
Public MustOverride ReadOnly Property BaseType As Type
public abstract Type BaseType { get; }
public:
virtual property Type^ BaseType {
	Type^ get () abstract;
}
abstract BaseType : Type

Property Value

Type: System..::.Type
The Type from which the current Type directly inherits, or nullNothingnullptra null reference (Nothing in Visual Basic) if the current Type represents the Object class or an interface.

Implements

_Type..::.BaseType
Remarks

The base type is the type from which the current type directly inherits. Object is the only type that does not have a base type, therefore nullNothingnullptra null reference (Nothing in Visual Basic) is returned as the base type of Object.

Interfaces inherit from zero or more base interfaces; therefore, this property returns nullNothingnullptra null reference (Nothing in Visual Basic) if the Type object represents an interface. The base interfaces can be determined with GetInterfaces or FindInterfaces.

If the current Type represents a constructed generic type, the base type reflects the generic arguments. For example, consider the following declarations:


Class B(Of U)
End Class
Class C(Of T)
    Inherits B(Of T)
End Class


class B<U> { }
class C<T> : B<T> { }


generic<typename U> ref class B { };
generic<typename T> ref class C : B<T> { };

For the constructed type C<int> (C(Of Integer) in Visual Basic), the BaseType property returns B<int>.

If the current Type represents a type parameter of a generic type definition, BaseType returns the class constraint, that is, the class the type parameter must inherit. If there is no class constraint, BaseType returns System..::.Object.

This property is read-only.

Examples

The following example demonstrates using the BaseType property.


Imports System

Class TestType

    Public Shared Sub Main()
        Dim t As Type = GetType(Integer)
        Console.WriteLine("{0} inherits from {1}.", t, t.BaseType)
    End Sub 'Main
End Class 'TestType


using System;
class TestType 
{
    public static void Main() 
    {
        Type t = typeof(int);
        Console.WriteLine("{0} inherits from {1}.", t,t.BaseType);
    }
}


using namespace System;
void main()
{
   Type^ t = int::typeid;
   Console::WriteLine( "{0} inherits from {1}.", t, t->BaseType );
}


Version Information

.NET Framework

Supported in: 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
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.
Microsoft is conducting an online survey to understand your opinion of the MSDN Web site. If you choose to participate, the online survey will be presented to you when you leave the MSDN Web site.

Would you like to participate?