Obtaining nested types

To retrieve nested types, call GetNestedTypes on the containing type.

For example:


using System;
using System.Reflection;
using System.Collections.Generic;

class MainClass
{
    static void Main()
    {
        foreach (Type t in typeof(System.Environment).GetNestedTypes())
            Console.WriteLine(t.FullName);
    }
}

The output:


System.Environment+SpecialFolderOption
System.Environment+SpecialFolder

using System;
using System.Reflection;
using System.Collections.Generic;

class MainClass
{
    static void Main()
    {
        Type t = typeof(System.Environment.SpecialFolder);
        Console.WriteLine(t.IsPublic);  // False 
        Console.WriteLine(t.IsNestedPublic);  // True
    }
}

The output:


False
True
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.