CodeAttributeArgumentCollection Class
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.
Represents a collection of CodeAttributeArgument objects.
public ref class CodeAttributeArgumentCollection : System::Collections::CollectionBase
public class CodeAttributeArgumentCollection : System.Collections.CollectionBase
type CodeAttributeArgumentCollection = class
inherit CollectionBase
Public Class CodeAttributeArgumentCollection
Inherits CollectionBase
- Inheritance
Examples
The following example demonstrates the use of the CodeAttributeArgumentCollection class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point.
// Creates an empty CodeAttributeArgumentCollection.
CodeAttributeArgumentCollection collection = new CodeAttributeArgumentCollection();
// Adds a CodeAttributeArgument to the collection.
collection.Add( new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)) );
// Adds an array of CodeAttributeArgument objects to the collection.
CodeAttributeArgument[] arguments = { new CodeAttributeArgument(), new CodeAttributeArgument() };
collection.AddRange( arguments );
// Adds a collection of CodeAttributeArgument objects to
// the collection.
CodeAttributeArgumentCollection argumentsCollection = new CodeAttributeArgumentCollection();
argumentsCollection.Add( new CodeAttributeArgument("TestBooleanArgument", new CodePrimitiveExpression(true)) );
argumentsCollection.Add( new CodeAttributeArgument("TestIntArgument", new CodePrimitiveExpression(1)) );
collection.AddRange( argumentsCollection );
// Tests for the presence of a CodeAttributeArgument
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true));
int itemIndex = -1;
if( collection.Contains( testArgument ) )
itemIndex = collection.IndexOf( testArgument );
// Copies the contents of the collection beginning at index 0,
// to the specified CodeAttributeArgument array.
// 'arguments' is a CodeAttributeArgument array.
collection.CopyTo( arguments, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
// Inserts a CodeAttributeArgument at index 0 of the collection.
collection.Insert( 0, new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)) );
// Removes the specified CodeAttributeArgument from the collection.
CodeAttributeArgument argument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true));
collection.Remove( argument );
// Removes the CodeAttributeArgument at index 0.
collection.RemoveAt(0);
' Creates an empty CodeAttributeArgumentCollection.
Dim collection As New CodeAttributeArgumentCollection()
' Adds a CodeAttributeArgument to the collection.
collection.Add(New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True)))
' Adds an array of CodeAttributeArgument objects to the collection.
Dim arguments As CodeAttributeArgument() = {New CodeAttributeArgument(), New CodeAttributeArgument()}
collection.AddRange(arguments)
' Adds a collection of CodeAttributeArgument objects to the collection.
Dim argumentsCollection As New CodeAttributeArgumentCollection()
argumentsCollection.Add(New CodeAttributeArgument("TestBooleanArgument", New CodePrimitiveExpression(True)))
argumentsCollection.Add(New CodeAttributeArgument("TestIntArgument", New CodePrimitiveExpression(1)))
collection.AddRange(argumentsCollection)
' Tests for the presence of a CodeAttributeArgument in
' the collection, and retrieves its index if it is found.
Dim testArgument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True))
Dim itemIndex As Integer = -1
If collection.Contains(testArgument) Then
itemIndex = collection.IndexOf(testArgument)
End If
' Copies the contents of the collection beginning at index 0,
' to the specified CodeAttributeArgument array.
' 'arguments' is a CodeAttributeArgument array.
collection.CopyTo(arguments, 0)
' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count
' Inserts a CodeAttributeArgument at index 0 of the collection.
collection.Insert(0, New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True)))
' Removes the specified CodeAttributeArgument from the collection.
Dim argument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True))
collection.Remove(argument)
' Removes the CodeAttributeArgument at index 0.
collection.RemoveAt(0)
Remarks
The CodeAttributeArgumentCollection class provides a simple collection object that can be used to store a set of CodeAttributeArgument objects.
Constructors
| Name | Description |
|---|---|
| CodeAttributeArgumentCollection() |
Initializes a new instance of the CodeAttributeArgumentCollection class. |
| CodeAttributeArgumentCollection(CodeAttributeArgument[]) |
Initializes a new instance of the CodeAttributeArgumentCollection class containing the specified array of CodeAttributeArgument objects. |
| CodeAttributeArgumentCollection(CodeAttributeArgumentCollection) |
Initializes a new instance of the CodeAttributeArgumentCollection class containing the elements of the specified source collection. |
Properties
| Name | Description |
|---|---|
| Item[Int32] |
Gets or sets the CodeAttributeArgument object at the specified index in the collection. |
Methods
| Name | Description |
|---|---|
| Add(CodeAttributeArgument) |
Adds the specified CodeAttributeArgument object to the collection. |
| AddRange(CodeAttributeArgument[]) |
Copies the elements of the specified CodeAttributeArgument array to the end of the collection. |
| AddRange(CodeAttributeArgumentCollection) |
Copies the contents of another CodeAttributeArgumentCollection object to the end of the collection. |
| Contains(CodeAttributeArgument) |
Gets a value that indicates whether the collection contains the specified CodeAttributeArgument object. |
| CopyTo(CodeAttributeArgument[], Int32) |
Copies the collection objects to a one-dimensional Array instance beginning at the specified index. |
| IndexOf(CodeAttributeArgument) |
Gets the index of the specified CodeAttributeArgument object in the collection, if it exists in the collection. |
| Insert(Int32, CodeAttributeArgument) |
Inserts the specified CodeAttributeArgument object into the collection at the specified index. |
| Remove(CodeAttributeArgument) |
Removes the specified CodeAttributeArgument object from the collection. |