TypeBuilder.DefineField 方法

定義

將新欄位加入動態類型中。

多載

DefineField(String, Type, FieldAttributes)

將新欄位加入類型,指定其名稱、屬性和欄位類型。

DefineField(String, Type, Type[], Type[], FieldAttributes)

將新欄位加入此類型,並指定其名稱、屬性、欄位類型和自訂修飾詞。

DefineField(String, Type, FieldAttributes)

將新欄位加入類型,指定其名稱、屬性和欄位類型。

public:
 System::Reflection::Emit::FieldBuilder ^ DefineField(System::String ^ fieldName, Type ^ type, System::Reflection::FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField (string fieldName, Type type, System.Reflection.FieldAttributes attributes);
member this.DefineField : string * Type * System.Reflection.FieldAttributes -> System.Reflection.Emit.FieldBuilder
Public Function DefineField (fieldName As String, type As Type, attributes As FieldAttributes) As FieldBuilder

參數

fieldName
String

欄位的名稱。 fieldName 不能包含內嵌的 null。

type
Type

欄位的型別。

attributes
FieldAttributes

欄位的屬性。

傳回

FieldBuilder

定義的欄位。

例外狀況

fieldName 的長度為零。

-或- type 為 System.Void。

-或- 為這個欄位的父類別指定了總大小。

fieldNamenull

先前使用 CreateType() 建立的類型。

適用於

DefineField(String, Type, Type[], Type[], FieldAttributes)

將新欄位加入此類型,並指定其名稱、屬性、欄位類型和自訂修飾詞。

public:
 System::Reflection::Emit::FieldBuilder ^ DefineField(System::String ^ fieldName, Type ^ type, cli::array <Type ^> ^ requiredCustomModifiers, cli::array <Type ^> ^ optionalCustomModifiers, System::Reflection::FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField (string fieldName, Type type, Type[]? requiredCustomModifiers, Type[]? optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
public System.Reflection.Emit.FieldBuilder DefineField (string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, System.Reflection.FieldAttributes attributes);
member this.DefineField : string * Type * Type[] * Type[] * System.Reflection.FieldAttributes -> System.Reflection.Emit.FieldBuilder
Public Function DefineField (fieldName As String, type As Type, requiredCustomModifiers As Type(), optionalCustomModifiers As Type(), attributes As FieldAttributes) As FieldBuilder

參數

fieldName
String

欄位的名稱。 fieldName 不能包含內嵌的 null。

type
Type

欄位的型別。

requiredCustomModifiers
Type[]

類型陣列,代表欄位的必要自訂修飾詞,例如 IsConstModifier

optionalCustomModifiers
Type[]

類型陣列,代表欄位的選擇性自訂修飾詞,例如 IsConstModifier

attributes
FieldAttributes

欄位的屬性。

傳回

FieldBuilder

定義的欄位。

例外狀況

fieldName 的長度為零。

-或- type 為 System.Void。

-或- 為這個欄位的父類別指定了總大小。

fieldNamenull

先前使用 CreateType() 建立的類型。

備註

針對 managed 編譯器的設計工具會提供此多載。

適用於