Export (0) Print
Expand All

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
[C#]
public FieldBuilder DefineField(
 string fieldName,
 Type type,
 FieldAttributes attributes
);
[C++]
public: FieldBuilder* DefineField(
 String* fieldName,
 Type* type,
 FieldAttributes attributes
);
[JScript]
public function DefineField(
   fieldName : String,
 type : Type,
 attributes : FieldAttributes
) : FieldBuilder;

Parameters

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

Return Value

The defined field.

Exceptions

Exception Type Condition
ArgumentException The length of fieldName is zero.

-or-

type is System.Void.

-or-

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.

Requirements

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

Show:
© 2014 Microsoft