C# Type IsNested
Description
Type IsNested
gets a value indicating whether the current
Type object represents a type whose definition is nested inside the definition
of another type.
Syntax
Type.IsNested
has the following syntax.
public bool IsNested { get; }
Example
The following code example displays the value of the IsNested property for both a protected nested class and a public nested class.
using System;/*www . j a v a 2 s .co m*/
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);
}
}
The code above generates the following result.