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)
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.
Note |
|---|
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.
using System; public class Example { protected class NestedProtected { } public class NestedPublic { } public static void Main() { Type t = typeof(NestedProtected); Console.WriteLine("Is {0} nested? {1}", t.FullName, t.IsNested); t = typeof(NestedPublic); Console.WriteLine("Is {0} nested? {1}", t.FullName, t.IsNested); } } /* This example produces the following output: Is Example+NestedProtected nested? True Is Example+NestedPublic nested? True */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note