Partager via


VirtualTypeBuilder.FieldInfoCollection.Add Method (String, Type, array<Attribute , FieldAttributes)

Adds a FieldInfo to the end of the collection.

Namespace:  Microsoft.VisualStudio.Shell.Design
Assembly:  Microsoft.VisualStudio.Shell.Design (in Microsoft.VisualStudio.Shell.Design.dll)

Syntax

'Declaration
Public Function Add ( _
    name As String, _
    fieldType As Type, _
    attributes As Attribute(), _
    fieldAttributes As FieldAttributes _
) As Integer
public int Add(
    string name,
    Type fieldType,
    Attribute[] attributes,
    FieldAttributes fieldAttributes
)
public:
int Add(
    String^ name, 
    Type^ fieldType, 
    array<Attribute^>^ attributes, 
    FieldAttributes fieldAttributes
)
member Add : 
        name:string * 
        fieldType:Type * 
        attributes:Attribute[] * 
        fieldAttributes:FieldAttributes -> int
public function Add(
    name : String, 
    fieldType : Type, 
    attributes : Attribute[], 
    fieldAttributes : FieldAttributes
) : int

Parameters

  • name
    Type: String

    The name of the field to add.

  • fieldType
    Type: Type

    The type of field.

  • attributes
    Type: array<Attribute[]

    This parameter is used to configure the class member appropriately. Add only accepts the values of MemberAttributes that fit into the AccessMask or ScopeMask categories.

  • fieldAttributes
    Type: FieldAttributes

    This parameter specifies additional field attributes for this member. The default field attribute is Public. The only field attributes currently supported are Public and Static.

Return Value

Type: Int32
The index at which the value has been added.

Exceptions

Exception Condition
ArgumentNullException

name or fieldType or an element in attributes is nulla null reference (Nothing in Visual Basic). attributes itself may be nulla null reference (Nothing in Visual Basic).

ArgumentException

fieldType is not a run-time type

-or-

fieldAttributes does not contain Public or contains set bits other than Public and Static, or attributes passed in through the attributes parameter cannot be applied to fields.

.NET Framework Security

See Also

Reference

VirtualTypeBuilder.FieldInfoCollection Class

Add Overload

Microsoft.VisualStudio.Shell.Design Namespace