TypeBuilder.DefineNestedType TypeBuilder.DefineNestedType TypeBuilder.DefineNestedType TypeBuilder.DefineNestedType Method

定义

定义嵌套类型。Defines a nested type.

重载

DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) 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, Type[]) DefineNestedType(String, TypeAttributes, Type, Type[]) DefineNestedType(String, TypeAttributes, Type, Type[]) 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, Int32) DefineNestedType(String, TypeAttributes, Type, Int32) DefineNestedType(String, TypeAttributes, Type, Int32) 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, PackingSize) DefineNestedType(String, TypeAttributes, Type, PackingSize) DefineNestedType(String, TypeAttributes, Type, PackingSize) DefineNestedType(String, TypeAttributes, Type, PackingSize)

定义嵌套类型,其名称、属性、它所扩展的类型以及封装大小已给定。Defines a nested type, given its name, attributes, the type that it extends, and the packing size.

DefineNestedType(String, TypeAttributes) DefineNestedType(String, TypeAttributes) DefineNestedType(String, TypeAttributes) DefineNestedType(String, TypeAttributes)

已知名称和属性,定义嵌套类型。Defines a nested type, given its name and attributes.

DefineNestedType(String) DefineNestedType(String) DefineNestedType(String) DefineNestedType(String)

定义嵌套的类型,并给定其名称。Defines a nested type, given its name.

DefineNestedType(String, TypeAttributes, Type) DefineNestedType(String, TypeAttributes, Type) DefineNestedType(String, TypeAttributes, Type) DefineNestedType(String, TypeAttributes, Type)

定义嵌套类型,其名称、属性以及它所扩展的类型已给定。Defines a nested type, given its name, attributes, and the type that it extends.

DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) DefineNestedType(String, TypeAttributes, Type, PackingSize, Int32) 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);
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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null 值。name cannot contain embedded null values.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

parent
Type Type Type Type

此嵌套类型扩展的类型。The type that the nested type extends.

packSize
PackingSize PackingSize PackingSize PackingSize

此类型的封装大小。The packing size of the type.

typeSize
Int32 Int32 Int32 Int32

此类型的总大小。The total size of the type.

返回

已定义的嵌套类型。The defined nested type.

DefineNestedType(String, TypeAttributes, Type, Type[]) DefineNestedType(String, TypeAttributes, Type, Type[]) DefineNestedType(String, TypeAttributes, Type, Type[]) 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);
[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
Public Function DefineNestedType (name As String, attr As TypeAttributes, parent As Type, interfaces As Type()) As TypeBuilder

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

parent
Type Type Type Type

此嵌套类型扩展的类型。The type that the nested type extends.

interfaces
Type[]

此嵌套类型实现的接口。The interfaces that the nested type implements.

返回

已定义的嵌套类型。The defined nested type.

异常

未指定嵌套属性。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- name 的长度为零或大于 1023。The length of name is zero or greater than 1023.

-or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

namenullname is null.

-or- interfaces 数组的一个元素是 nullAn element of the interfaces array is null.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

DefineNestedType(String, TypeAttributes, Type, Int32) DefineNestedType(String, TypeAttributes, Type, Int32) DefineNestedType(String, TypeAttributes, Type, Int32) 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);
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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

parent
Type Type Type Type

此嵌套类型扩展的类型。The type that the nested type extends.

typeSize
Int32 Int32 Int32 Int32

此类型的总大小。The total size of the type.

返回

已定义的嵌套类型。The defined nested type.

异常

未指定嵌套属性。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- name 的长度为零或大于 1023。The length of name is zero or greater than 1023.

-or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

DefineNestedType(String, TypeAttributes, Type, PackingSize) DefineNestedType(String, TypeAttributes, Type, PackingSize) DefineNestedType(String, TypeAttributes, Type, PackingSize) 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);
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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

parent
Type Type Type Type

此嵌套类型扩展的类型。The type that the nested type extends.

packSize
PackingSize PackingSize PackingSize PackingSize

此类型的封装大小。The packing size of the type.

返回

已定义的嵌套类型。The defined nested type.

异常

未指定嵌套属性。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- name 的长度为零或大于 1023。The length of name is zero or greater than 1023.

- 或 --or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

DefineNestedType(String, TypeAttributes) DefineNestedType(String, TypeAttributes) DefineNestedType(String, TypeAttributes) 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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

返回

已定义的嵌套类型。The defined nested type.

异常

未指定嵌套属性。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- name 的长度为零或大于 1023。The length of name is zero or greater than 1023.

- 或 --or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

DefineNestedType(String) DefineNestedType(String) DefineNestedType(String) 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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

返回

已定义的嵌套类型。The defined nested type.

异常

name 长度为零或大于 1023。Length of name is zero or greater than 1023.

-or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

DefineNestedType(String, TypeAttributes, Type) DefineNestedType(String, TypeAttributes, Type) DefineNestedType(String, TypeAttributes, Type) 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);
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

参数

name
String String String String

类型的短名称。The short name of the type. name 不能包含嵌入的 null。name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

此类型的属性。The attributes of the type.

parent
Type Type Type Type

此嵌套类型扩展的类型。The type that the nested type extends.

返回

已定义的嵌套类型。The defined nested type.

异常

未指定嵌套属性。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- name 的长度为零或大于 1023。The length of name is zero or greater than 1023.

- 或 --or- 此操作将在当前程序集中创建一个具有重复 FullName 的类型。This operation would create a type with a duplicate FullName in the current assembly.

注解

即使已对封闭类型调用了CreateType方法,也可以使用此方法创建嵌套类型。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

嵌套类型需要先完成,然后才能使用GetMembersGetNestedTypeGetNestedTypes进行反射。The nested type needs to be complete before you can reflect on it using GetMembers, GetNestedType, or GetNestedTypes.

CreateType有关应如何完成嵌套类型和嵌套类型的说明,请参阅的说明。See the description of CreateType for the order in which nested types and nesting types should be completed.

如果name与之前定义的类型或嵌套类型的名称相同,则不一定会创建重复的名称。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.

适用于