Share via


VirtualTypeBuilder.AttributeCollection.Add Method

Adds an Attribute to the end of the VirtualTypeBuilder.AttributeCollection.

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

Syntax

'Declaration
Public Function Add ( _
    value As Attribute _
) As Integer
public int Add(
    Attribute value
)
public:
int Add(
    Attribute^ value
)
member Add : 
        value:Attribute -> int
public function Add(
    value : Attribute
) : int

Parameters

  • value
    Type: Attribute

    The Attribute to be added to the end of the collection.

Return Value

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

Exceptions

Exception Condition
ArgumentException

value cannot be placed on a class.

ArgumentNullException

The attribute is nulla null reference (Nothing in Visual Basic).

Remarks

Attributes are added in the order you would expect them to be declared on the class. The following code example shows how to add attributes that would be declared on a physical class.

[Browsable(true)]
[Description("Hello world")]
public class MyClass {}

The following code example shows the order in which to add attributes.

Add(new DescriptionAttribute("Hello world"));
Add(BrowsableAttribute.Yes);

Attributes that are marked as "allow multiple" will be added multiple times, while those not marked with "allow multiple" will only be added once, with the last one added taking precedence. This is in the same manner as a compiler.

.NET Framework Security

See Also

Reference

VirtualTypeBuilder.AttributeCollection Class

Microsoft.VisualStudio.Shell.Design Namespace

CollectionBase