TypeBuilder.DefineNestedType 方法

定義

定義巢狀類型。

多載

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

定義巢狀類型,並指定其名稱、屬性、擴充的類型和實作的介面。

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

定義巢狀類型,並指定其名稱、屬性、大小和擴充的類型。

DefineNestedType(String, TypeAttributes, Type, PackingSize)

定義巢狀類型,並指定其名稱、屬性、擴充的類型和封裝大小。

DefineNestedType(String)

定義巢狀類型,並指定其名稱。

DefineNestedType(String, TypeAttributes, Type)

定義巢狀類型,並指定其名稱、屬性和擴充的類型。

DefineNestedType(String, TypeAttributes)

定義巢狀類型,並指定其名稱及屬性。

DefineNestedType(String, TypeAttributes, Type, Int32)

定義巢狀型別,指定其名稱、屬性、型別的總大小及其擴充的型別。

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

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱、屬性、擴充的類型和實作的介面。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

attr
TypeAttributes

類型的屬性。

parent
Type

巢狀型別所擴充的型別。

interfaces
Type[]

巢狀類型實作的介面。

傳回

定義的巢狀型別。

屬性

例外狀況

未指定巢狀屬性。

-或-

這個類型已密封。

-或-

這個型別是陣列。

-或-

這個型別是介面,但巢狀型別不是介面。

-或-

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

-或-

interfaces 陣列的項目是 null

備註

這個方法可以用來建立巢狀類型,即使在封入類型上呼叫方法之後 CreateType 也一定。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的型別或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於

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

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱、屬性、大小和擴充的類型。

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

型別的簡短名稱。 name 不能包含內嵌的 null 值。

attr
TypeAttributes

類型的屬性。

parent
Type

巢狀型別所擴充的型別。

packSize
PackingSize

類型的封裝大小。

typeSize
Int32

型別的總大小。

傳回

定義的巢狀型別。

適用於

DefineNestedType(String, TypeAttributes, Type, PackingSize)

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱、屬性、擴充的類型和封裝大小。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

attr
TypeAttributes

類型的屬性。

parent
Type

巢狀型別所擴充的型別。

packSize
PackingSize

類型的封裝大小。

傳回

定義的巢狀型別。

例外狀況

未指定巢狀屬性。

-或-

這個類型已密封。

-或-

這個型別是陣列。

-或-

這個型別是介面,但巢狀型別不是介面。

-或-

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

備註

這個方法可以用來建立巢狀類型,即使在封入類型上呼叫方法之後 CreateType 也一定。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的型別或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於

DefineNestedType(String)

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

傳回

定義的巢狀型別。

例外狀況

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

備註

這個方法可以用來建立巢狀類型,即使在封入類型上呼叫方法之後 CreateType 也一定。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的型別或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於

DefineNestedType(String, TypeAttributes, Type)

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱、屬性和擴充的類型。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

attr
TypeAttributes

類型的屬性。

parent
Type

巢狀型別所擴充的型別。

傳回

定義的巢狀型別。

例外狀況

未指定巢狀屬性。

-或-

這個類型已密封。

-或-

這個型別是陣列。

-或-

這個型別是介面,但巢狀型別不是介面。

-或-

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

備註

即使在封入類型上呼叫 方法之後, CreateType 這個方法仍可用來建立巢狀類型。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的類型或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於

DefineNestedType(String, TypeAttributes)

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀類型,並指定其名稱及屬性。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

attr
TypeAttributes

類型的屬性。

傳回

定義的巢狀型別。

例外狀況

未指定巢狀屬性。

-或-

這個類型已密封。

-或-

這個型別是陣列。

-或-

這個型別是介面,但巢狀型別不是介面。

-或-

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

備註

即使在封入類型上呼叫 方法之後, CreateType 這個方法仍可用來建立巢狀類型。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的類型或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於

DefineNestedType(String, TypeAttributes, Type, Int32)

來源:
TypeBuilder.cs
來源:
TypeBuilder.cs
來源:
TypeBuilder.cs

定義巢狀型別,指定其名稱、屬性、型別的總大小及其擴充的型別。

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

型別的簡短名稱。 name 不能包含內嵌的 null。

attr
TypeAttributes

類型的屬性。

parent
Type

巢狀型別所擴充的型別。

typeSize
Int32

型別的總大小。

傳回

定義的巢狀型別。

例外狀況

未指定巢狀屬性。

-或-

這個類型已密封。

-或-

這個型別是陣列。

-或-

這個型別是介面,但巢狀型別不是介面。

-或-

name 的長度為零或大於 1023。

-或-

這項作業會以目前組件中的重複 FullName 來建立類型。

namenull

備註

即使在封入類型上呼叫 方法之後, CreateType 這個方法仍可用來建立巢狀類型。

您必須先完成巢狀類型,才能使用 GetMembersGetNestedTypeGetNestedTypes 來反映。

如需巢狀類型和巢狀類型應該完成的順序,請參閱 的描述 CreateType

如果 name 與先前定義的類型或巢狀類型的名稱相同,則不一定建立重複的名稱。 若要重複,完整名稱必須相同,包括命名空間和所有巢狀類型。

適用於