This documentation is archived and is not being maintained.

TypeBuilder.DefineField Method

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

[Visual Basic]
Public Function DefineField( _
   ByVal fieldName As String, _
   ByVal type As Type, _
   ByVal attributes As FieldAttributes _
) As FieldBuilder
public FieldBuilder DefineField(
 string fieldName,
 Type type,
 FieldAttributes attributes
public: FieldBuilder* DefineField(
 String* fieldName,
 Type* type,
 FieldAttributes attributes
public function DefineField(
   fieldName : String,
 type : Type,
 attributes : FieldAttributes
) : FieldBuilder;


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

Return Value

The defined field.


Exception Type Condition
ArgumentException The length of fieldName is zero.


type is System.Void.


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

ArgumentNullException fieldName is a null reference (Nothing in Visual Basic).
InvalidOperationException The type was previously created using CreateType TypeBuilder.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

TypeBuilder Class | TypeBuilder Members | System.Reflection.Emit Namespace