TypeBuilder.DefineField 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向动态类型添加新字段。
重载
| 名称 | 说明 |
|---|---|
| DefineField(String, Type, FieldAttributes) |
向类型添加新字段,其中包含给定的名称、属性和字段类型。 |
| DefineField(String, Type, Type[], Type[], FieldAttributes) |
向类型添加新字段,其中包含给定的名称、属性、字段类型和自定义修饰符。 |
DefineField(String, Type, FieldAttributes)
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
向类型添加新字段,其中包含给定的名称、属性和字段类型。
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
字段的属性。
返回
定义的字段。
例外
fieldName 是 null。
该类型以前是使用 CreateType().
适用于
DefineField(String, Type, Type[], Type[], FieldAttributes)
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
向类型添加新字段,其中包含给定的名称、属性、字段类型和自定义修饰符。
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
字段的属性。
返回
定义的字段。
例外
fieldName 是 null。
该类型以前是使用 CreateType().
注解
此重载是为托管编译器的设计器提供的。