TypeBuilder.DefineNestedType Method

Definition

Defines a nested type.

Overloads

DefineNestedType(String, TypeAttributes, Type, Type[])

Defines a nested type, given its name, attributes, the type that it extends, and the interfaces that it implements.

DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32)

Defines a nested type, given its name, attributes, size, and the type that it extends.

DefineNestedType(String, TypeAttributes, Type, PackingSize)

Defines a nested type, given its name, attributes, the type that it extends, and the packing size.

DefineNestedType(String)

Defines a nested type, given its name.

DefineNestedType(String, TypeAttributes, Type)

Defines a nested type, given its name, attributes, and the type that it extends.

DefineNestedType(String, TypeAttributes)

Defines a nested type, given its name and attributes.

DefineNestedType(String, TypeAttributes, Type, Int32)

Defines a nested type, given its name, attributes, the total size of the type, and the type that it extends.

DefineNestedType(String, TypeAttributes, Type, Type[])

Defines a nested type, given its name, attributes, the type that it extends, and the interfaces that it implements.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, cli::array <Type ^> ^ interfaces);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type? parent, Type[]? interfaces);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent, Type[] interfaces);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent, Type[] interfaces);
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type * Type[] -> System.Reflection.Emit.TypeBuilder
[<System.Runtime.InteropServices.ComVisible(true)>]
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type * Type[] -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type, interfaces As Type()) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

attr
TypeAttributes

The attributes of the type.

parent
Type

The type that the nested type extends.

interfaces
Type[]

The interfaces that the nested type implements.

Returns

The defined nested type.

Attributes

Exceptions

The nested attribute is not specified.

-or-

This type is sealed.

-or-

This type is an array.

-or-

This type is an interface, but the nested type is not an interface.

-or-

The length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

-or-

An element of the interfaces array is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to

DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32)

Defines a nested type, given its name, attributes, size, and the type that it extends.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, System::Reflection::Emit::PackingSize packSize, int typeSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type? parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent, System.Reflection.Emit.PackingSize packSize, int typeSize);
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type * System.Reflection.Emit.PackingSize * int -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type, packSize As PackingSize, typeSize As Integer) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded null values.

attr
TypeAttributes

The attributes of the type.

parent
Type

The type that the nested type extends.

packSize
PackingSize

The packing size of the type.

typeSize
Int32

The total size of the type.

Returns

The defined nested type.

Applies to

DefineNestedType(String, TypeAttributes, Type, PackingSize)

Defines a nested type, given its name, attributes, the type that it extends, and the packing size.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, System::Reflection::Emit::PackingSize packSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type? parent, System.Reflection.Emit.PackingSize packSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent, System.Reflection.Emit.PackingSize packSize);
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type * System.Reflection.Emit.PackingSize -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type, packSize As PackingSize) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

attr
TypeAttributes

The attributes of the type.

parent
Type

The type that the nested type extends.

packSize
PackingSize

The packing size of the type.

Returns

The defined nested type.

Exceptions

The nested attribute is not specified.

-or-

This type is sealed.

-or-

This type is an array.

-or-

This type is an interface, but the nested type is not an interface.

-or-

The length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to

DefineNestedType(String)

Defines a nested type, given its name.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name);
member this.DefineNestedType : string -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

Returns

The defined nested type.

Exceptions

Length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to

DefineNestedType(String, TypeAttributes, Type)

Defines a nested type, given its name, attributes, and the type that it extends.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type? parent);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent);
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

attr
TypeAttributes

The attributes of the type.

parent
Type

The type that the nested type extends.

Returns

The defined nested type.

Exceptions

The nested attribute is not specified.

-or-

This type is sealed.

-or-

This type is an array.

-or-

This type is an interface, but the nested type is not an interface.

-or-

The length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to

DefineNestedType(String, TypeAttributes)

Defines a nested type, given its name and attributes.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr);
member this.DefineNestedType : string * System.Reflection.TypeAttributes -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

attr
TypeAttributes

The attributes of the type.

Returns

The defined nested type.

Exceptions

The nested attribute is not specified.

-or-

This type is sealed.

-or-

This type is an array.

-or-

This type is an interface, but the nested type is not an interface.

-or-

The length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to

DefineNestedType(String, TypeAttributes, Type, Int32)

Defines a nested type, given its name, attributes, the total size of the type, and the type that it extends.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineNestedType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, int typeSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type? parent, int typeSize);
public System.Reflection.Emit.TypeBuilder DefineNestedType (string name, System.Reflection.TypeAttributes attr, Type parent, int typeSize);
member this.DefineNestedType : string * System.Reflection.TypeAttributes * Type * int -> System.Reflection.Emit.TypeBuilder
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type, typeSize As Integer) As TypeBuilder

Parameters

name
String

The short name of the type. name cannot contain embedded nulls.

attr
TypeAttributes

The attributes of the type.

parent
Type

The type that the nested type extends.

typeSize
Int32

The total size of the type.

Returns

The defined nested type.

Exceptions

The nested attribute is not specified.

-or-

This type is sealed.

-or-

This type is an array.

-or-

This type is an interface, but the nested type is not an interface.

-or-

The length of name is zero or greater than 1023.

-or-

This operation would create a type with a duplicate FullName in the current assembly.

name is null.

Remarks

This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

See the description of CreateType for the order in which nested types and nesting types should be completed.

A duplicate name is not necessarily created if name is identical to the name of a previously defined type or nested type. To be duplicates, the full names must be the same, including the namespace and all nesting types.

Applies to