C# TypeInfo GetNestedTypes()
Description
TypeInfo GetNestedTypes()
Returns the public types
nested in the current Type.
Syntax
TypeInfo.GetNestedTypes()
has the following syntax.
public Type[] GetNestedTypes()
Returns
TypeInfo.GetNestedTypes()
method returns
Example
Returns the public types nested in the current Type.
using System;// ww w . j a va 2 s . c om
using System.Reflection;
public class MyClass
{
public class NestClass
{
public static int myPublicInt=0;
}
public struct NestStruct
{
public static int myPublicInt=0;
}
}
public class MyMainClass
{
public static void Main()
{
Type myType=typeof(MyClass);
Type[] nestType=myType.GetNestedTypes();
Console.WriteLine("The number of nested types is {0}.", nestType.Length);
foreach(Type t in nestType)
Console.WriteLine("Nested type is {0}.", t.ToString());
}
}
The code above generates the following result.