Export (0) Print
Expand All

CodeCatchClauseCollection Class

Represents a collection of CodeCatchClause objects.

Namespace: System.CodeDom
Assembly: System (in system.dll)

[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class CodeCatchClauseCollection : CollectionBase
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class CodeCatchClauseCollection extends CollectionBase
SerializableAttribute 
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class CodeCatchClauseCollection extends CollectionBase
Not applicable.

The CodeCatchClauseCollection class provides a simple collection object that can be used to store a set of CodeCatchClause objects.

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.
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(System.ArgumentOutOfRangeException.
    class.ToType())));
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.get_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);

System.Object
   System.Collections.CollectionBase
    System.CodeDom.CodeCatchClauseCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft