Type.BaseType Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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; }

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.

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.

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

class B<U> { }
class C<T> : B<T> { }
Class B(Of U)
End Class
Class C(Of T)
    Inherits B(Of T)
End Class
generic<typename U> ref class B { };
generic<typename T> 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.


Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim t As Type = GetType(Integer)
      outputBlock.Text += String.Format("{0} inherits from {1}.", t, t.BaseType) & vbCrLf
   End Sub 'Main
End Class 'TestType
using System;
class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Type t = typeof(int);
      outputBlock.Text += String.Format("{0} inherits from {1}.", t, t.BaseType) + "\n";
   }
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

Type Class

System Namespace

Object

GetInterfaces

UnderlyingSystemType

IsSubclassOf