This documentation is archived and is not being maintained.

Type.IsNested Property

Gets a value indicating whether the current Type object represents a type whose definition is nested inside the definition of another type.

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

Public ReadOnly Property IsNested As Boolean

Property Value

Type: System.Boolean
true if the Type is nested inside another type; otherwise, false.

The IsNested property returns true for all nested types, regardless of visibility. To test for nesting and visibility at the same time, use the related properties IsNestedAssembly, IsNestedFamily, IsNestedFamANDAssem, IsNestedFamORAssem, IsNestedPrivate, or IsNestedPublic.


The VisibilityMask enumeration member selects the visibility attributes for a type.

The following code example displays the value of the IsNested property for both a protected nested class and a public nested class.

Imports System

Public Class Example
    Protected Class NestedProtected
    End Class

    Public Class NestedPublic
    End Class

    Public Shared Sub Main()
        With GetType(NestedProtected)
            Console.WriteLine("Is " & .FullName & " nested? " & .IsNested)
        End With
        With GetType(NestedPublic)
            Console.WriteLine("Is " & .FullName & " nested? " & .IsNested)
        End With
    End Sub
End Class

' This example produces the following output:
'Is Example+NestedProtected nested? True
'Is Example+NestedPublic nested? True 

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.