Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Public Class Example
   Protected Class NestedProtected
   End Class

   Public Class NestedPublic
   End Class

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      With GetType(NestedProtected)
         outputBlock.Text &= "Is " & .FullName & " nested? " & .IsNested & vbCrLf
      End With
      With GetType(NestedPublic)
         outputBlock.Text &= "Is " & .FullName & " nested? " & .IsNested & vbCrLf
      End With
   End Sub
End Class

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


Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.