Mono Class Library: System.Type Overview | Members

System.Type.GetNestedType Method

Returns the public nested type defined in the type represented by the current instance

public Type GetNestedType (string name)

Parameters

name
A string containing the name of the public nested type to return. Specify the unqualified name of the nested type.
Note: For example, for a type B nested within A, if typeA represents the type object for A, the correct invocation is typeA.GetNestedType("B").

Returns

A Type object representing the public nested type with the specified name, if found; otherwise, null.

Exceptions

TypeReason
ArgumentNullExceptionname is null.

Remarks

The search for name is case-sensitive.

Use the simple name of the nested class for name; do not qualify it with the name of the outer class. CLS rules require a naming pattern for nested types; see Partition I.

If the current instance represents an unassigned type parameter of a generic type or method definition, this method does not search the nested types of the class constraint.

Note: The name parameter cannot include type arguments. For example, passing "MyGenericNestedType<int>" to this method searches for a nested type with the text name "MyGenericNestedType<int>", rather than for a nested type named MyGenericNestedType that has one generic argument of type int.
Note: If the nested type is generic, what is returned is always a generic type definition.

For information on constructing nested generic types from their generic type definitions, see the Type.MakeGenericType(System.Type[]) method.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0