Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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 bool IsNested { get; }

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.

NoteNote:

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 Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Type t = typeof(NestedProtected);
      outputBlock.Text += String.Format("Is {0} nested? {1}", t.FullName, t.IsNested) + "\n";
      t = typeof(NestedPublic);
      outputBlock.Text += String.Format("Is {0} nested? {1}", t.FullName, t.IsNested) + "\n";
   }
}

/* This example produces the following output:

Is Example+NestedProtected nested? True
Is Example+NestedPublic nested? True 
 */


Silverlight

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.

Community Additions

Show:
© 2017 Microsoft