CodeCatchClauseCollection 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 CodeCatchClause objects.
public ref class CodeCatchClauseCollection : System::Collections::CollectionBase
public class CodeCatchClauseCollection : System.Collections.CollectionBase
type CodeCatchClauseCollection = class
inherit CollectionBase
Public Class CodeCatchClauseCollection
Inherits CollectionBase
- Inheritance
Examples
The following example demonstrates the use of the CodeCatchClauseCollection 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 CodeCatchClauseCollection.
CodeCatchClauseCollection collection = new CodeCatchClauseCollection();
// Adds a CodeCatchClause to the collection.
collection.Add( new CodeCatchClause("e") );
// Adds an array of CodeCatchClause objects to the collection.
CodeCatchClause[] clauses = { new CodeCatchClause(), new CodeCatchClause() };
collection.AddRange( clauses );
// Adds a collection of CodeCatchClause objects to the collection.
CodeCatchClauseCollection clausesCollection = new CodeCatchClauseCollection();
clausesCollection.Add( new CodeCatchClause("e", new CodeTypeReference(typeof(System.ArgumentOutOfRangeException))) );
clausesCollection.Add( new CodeCatchClause("e") );
collection.AddRange( clausesCollection );
// Tests for the presence of a CodeCatchClause in the
// collection, and retrieves its index if it is found.
CodeCatchClause testClause = new CodeCatchClause("e");
int itemIndex = -1;
if( collection.Contains( testClause ) )
itemIndex = collection.IndexOf( testClause );
// Copies the contents of the collection beginning at index 0 to the specified CodeCatchClause array.
// 'clauses' is a CodeCatchClause array.
collection.CopyTo( clauses, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
// Inserts a CodeCatchClause at index 0 of the collection.
collection.Insert( 0, new CodeCatchClause("e") );
// Removes the specified CodeCatchClause from the collection.
CodeCatchClause clause = new CodeCatchClause("e");
collection.Remove( clause );
// Removes the CodeCatchClause at index 0.
collection.RemoveAt(0);
' Creates an empty CodeCatchClauseCollection.
Dim collection As New CodeCatchClauseCollection()
' Adds a CodeCatchClause to the collection.
collection.Add(New CodeCatchClause("e"))
' Adds an array of CodeCatchClause objects to the collection.
Dim clauses As CodeCatchClause() = {New CodeCatchClause(), New CodeCatchClause()}
collection.AddRange(clauses)
' Adds a collection of CodeCatchClause objects to the collection.
Dim clausesCollection As New CodeCatchClauseCollection()
clausesCollection.Add(New CodeCatchClause("e", New CodeTypeReference(GetType(System.ArgumentOutOfRangeException))))
clausesCollection.Add(New CodeCatchClause("e"))
collection.AddRange(clausesCollection)
' Tests for the presence of a CodeCatchClause in the
' collection, and retrieves its index if it is found.
Dim testClause As New CodeCatchClause("e")
Dim itemIndex As Integer = -1
If collection.Contains(testClause) Then
itemIndex = collection.IndexOf(testClause)
End If
' Copies the contents of the collection beginning at index 0 to the specified CodeCatchClause array.
' 'clauses' is a CodeCatchClause array.
collection.CopyTo(clauses, 0)
' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count
' Inserts a CodeCatchClause at index 0 of the collection.
collection.Insert(0, New CodeCatchClause("e"))
' Removes the specified CodeCatchClause from the collection.
Dim clause As New CodeCatchClause("e")
collection.Remove(clause)
' Removes the CodeCatchClause at index 0.
collection.RemoveAt(0)
Remarks
The CodeCatchClauseCollection class provides a simple collection object that can be used to store a set of CodeCatchClause objects.
Constructors
| Name | Description |
|---|---|
| CodeCatchClauseCollection() |
Initializes a new instance of the CodeCatchClauseCollection class. |
| CodeCatchClauseCollection(CodeCatchClause[]) |
Initializes a new instance of the CodeCatchClauseCollection class containing the specified array of CodeCatchClause objects. |
| CodeCatchClauseCollection(CodeCatchClauseCollection) |
Initializes a new instance of the CodeCatchClauseCollection class containing the elements of the specified source collection. |
Properties
| Name | Description |
|---|---|
| Item[Int32] |
Gets or sets the CodeCatchClause object at the specified index in the collection. |
Methods
| Name | Description |
|---|---|
| Add(CodeCatchClause) |
Adds the specified CodeCatchClause object to the collection. |
| AddRange(CodeCatchClause[]) |
Copies the elements of the specified CodeCatchClause array to the end of the collection. |
| AddRange(CodeCatchClauseCollection) |
Copies the contents of another CodeCatchClauseCollection object to the end of the collection. |
| Contains(CodeCatchClause) |
Gets a value that indicates whether the collection contains the specified CodeCatchClause object. |
| CopyTo(CodeCatchClause[], Int32) |
Copies the collection objects to a one-dimensional Array instance beginning at the specified index. |
| IndexOf(CodeCatchClause) |
Gets the index of the specified CodeCatchClause object in the collection, if it exists in the collection. |
| Insert(Int32, CodeCatchClause) |
Inserts the specified CodeCatchClause object into the collection at the specified index. |
| Remove(CodeCatchClause) |
Removes the specified CodeCatchClause object from the collection. |