TypeBuilder.DefineNestedType 方法

定義

定義巢狀類型。Defines a nested type.

多載

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[])

定義巢狀類型,並指定其名稱、屬性、擴充的類型和實作的介面。Defines a nested type, given its name, attributes, the type that it extends, and the interfaces that it implements.

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)

定義巢狀類型,並指定其名稱、屬性、擴充的類型和封裝大小。Defines a nested type, given its name, attributes, the type that it extends, and the packing size.

DefineNestedType(String, TypeAttributes)

定義巢狀類型,並指定其名稱及屬性。Defines a nested type, given its name and attributes.

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, 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

參數

name
String

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null 值。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.

傳回

TypeBuilder

定義的巢狀型別。The defined nested 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);
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

參數

name
String

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。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.

傳回

TypeBuilder

定義的巢狀型別。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.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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)

定義巢狀型別,指定其名稱、屬性、型別的總大小及其擴充的型別。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

參數

name
String

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。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.

傳回

TypeBuilder

定義的巢狀型別。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.

備註

即使在封入 CreateType 類型上呼叫方法之後,也可以使用這個方法來建立巢狀型別。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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)

定義巢狀類型,並指定其名稱、屬性、擴充的類型和封裝大小。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

參數

name
String

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。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.

傳回

TypeBuilder

定義的巢狀型別。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.

備註

即使在封入 CreateType 類型上呼叫方法之後,也可以使用這個方法來建立巢狀型別。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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)

定義巢狀類型,並指定其名稱及屬性。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

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。name cannot contain embedded nulls.

attr
TypeAttributes

類型的屬性。The attributes of the type.

傳回

TypeBuilder

定義的巢狀型別。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.

備註

即使在封入 CreateType 類型上呼叫方法之後,也可以使用這個方法來建立巢狀型別。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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)

定義巢狀類型,並指定其名稱。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

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。name cannot contain embedded nulls.

傳回

TypeBuilder

定義的巢狀型別。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.

namenullname is null.

備註

即使在封入 CreateType 類型上呼叫方法之後,也可以使用這個方法來建立巢狀型別。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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)

定義巢狀類型,並指定其名稱、屬性和擴充的類型。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

參數

name
String

型別的簡短名稱。The short name of the type. name 不能包含內嵌的 null。name cannot contain embedded nulls.

attr
TypeAttributes

類型的屬性。The attributes of the type.

parent
Type

巢狀型別所擴充的型別。The type that the nested type extends.

傳回

TypeBuilder

定義的巢狀型別。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.

備註

即使在封入 CreateType 類型上呼叫方法之後,也可以使用這個方法來建立巢狀型別。This method can be used to create nested types even after the CreateType method has been called on the enclosing type.

您必須先完成巢狀型別,才能使用、或來反映它 GetMembers GetNestedType GetNestedTypesThe 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.

適用於