TypeBuilder.DefineField Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a new field to the dynamic type.
Overloads
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) |
Adds a new field to the type, with the given name, attributes, field type, and custom modifiers. |
DefineField(String, Type, FieldAttributes)
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
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
Public Function DefineField (fieldName As String, type As Type, attributes As FieldAttributes) As FieldBuilder
Parameters
- fieldName
- String
The name of the field. fieldName
cannot contain embedded nulls.
- type
- Type
The type of the field.
- attributes
- FieldAttributes
The attributes of the field.
Returns
The defined field.
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.
fieldName
is null
.
The type was previously created using CreateType().
Applies to
DefineField(String, Type, Type[], Type[], FieldAttributes)
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
- Source:
- TypeBuilder.cs
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);
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
Parameters
- fieldName
- String
The name of the field. fieldName
cannot contain embedded nulls.
- 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
The attributes of the field.
Returns
The defined field.
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.
fieldName
is null
.
The type was previously created using CreateType().
Remarks
This overload is provided for designers of managed compilers.