CodeCatchClauseCollection Class
Represents a collection of CodeCatchClause objects.
For a list of all members of this type, see CodeCatchClauseCollection Members.
System.Object
System.Collections.CollectionBase
System.CodeDom.CodeCatchClauseCollection
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeCatchClauseCollection Inherits CollectionBase [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeCatchClauseCollection : CollectionBase [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeCatchClauseCollection : public CollectionBase [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeCatchClauseCollection extends CollectionBase
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The CodeCatchClauseCollection class provides a simple collection object that can be used to store a set of CodeCatchClause objects.
Example
[Visual Basic] ' 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) [C#] // 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); [C++] // Creates an empty CodeCatchClauseCollection. CodeCatchClauseCollection* collection = new CodeCatchClauseCollection(); // Adds a CodeCatchClause to the collection. collection->Add( new CodeCatchClause(S"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(S"e", new CodeTypeReference(__typeof(System::ArgumentOutOfRangeException))) ); clausesCollection->Add( new CodeCatchClause(S"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(S"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(S"e") ); // Removes the specified CodeCatchClause from the collection. CodeCatchClause* clause = new CodeCatchClause(S"e"); collection->Remove( clause ); // Removes the CodeCatchClause at index 0. collection->RemoveAt(0);
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CodeCatchClauseCollection Members | System.CodeDom Namespace | CodeCatchClause