TypeBuilder.DefineField TypeBuilder.DefineField TypeBuilder.DefineField Method

Definition

Adds a new field to the dynamic type.

Overloads

DefineField(String, Type, FieldAttributes) DefineField(String, Type, FieldAttributes) DefineField(String, Type, FieldAttributes)

Adds a new field to the type, with the given name, attributes, and field type.

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

Adds a new field to the type, with the given name, attributes, field type, and custom modifiers.

DefineField(String, Type, FieldAttributes) DefineField(String, Type, FieldAttributes) DefineField(String, Type, FieldAttributes)

Adds a new field to the type, with the given name, attributes, and field type.

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

Parameters

fieldName
String String String

The name of the field. fieldName cannot contain embedded nulls.

type
Type Type Type

The type of the field

attributes
FieldAttributes FieldAttributes FieldAttributes

The attributes of the field.

Returns

Exceptions

The length of fieldName is zero.

-or-

type is System.Void.

-or-

A total size was specified for the parent class of this field.

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

Adds a new field to the type, with the given name, attributes, field type, and custom modifiers.

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);
member this.DefineField : string * Type * Type[] * Type[] * System.Reflection.FieldAttributes -> System.Reflection.Emit.FieldBuilder

Parameters

fieldName
String String String

The name of the field. fieldName cannot contain embedded nulls.

type
Type Type Type

The type of the field

requiredCustomModifiers
Type[]

An array of types representing the required custom modifiers for the field, such as IsConstModifier.

optionalCustomModifiers
Type[]

An array of types representing the optional custom modifiers for the field, such as IsConstModifier.

attributes
FieldAttributes FieldAttributes FieldAttributes

The attributes of the field.

Returns

Exceptions

The length of fieldName is zero.

-or-

type is System.Void.

-or-

A total size was specified for the parent class of this field.

Remarks

This overload is provided for designers of managed compilers.

Applies to