This documentation is archived and is not being maintained.

CodeParameterDeclarationExpressionCollection Class

Represents a collection of CodeParameterDeclarationExpression objects.

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

public class CodeParameterDeclarationExpressionCollection : CollectionBase

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

The following example demonstrates how to use the CodeParameterDeclarationExpressionCollection 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 CodeParameterDeclarationExpressionCollection.
CodeParameterDeclarationExpressionCollection collection = new CodeParameterDeclarationExpressionCollection();

// Adds a CodeParameterDeclarationExpression to the collection.
collection.Add( new CodeParameterDeclarationExpression(typeof(int), "testIntArgument") );

// Adds an array of CodeParameterDeclarationExpression objects  
// to the collection.
CodeParameterDeclarationExpression[] parameters = { new CodeParameterDeclarationExpression(typeof(int), "testIntArgument"), new CodeParameterDeclarationExpression(typeof(bool), "testBoolArgument") };
collection.AddRange( parameters );

// Adds a collection of CodeParameterDeclarationExpression objects  
// to the collection.
CodeParameterDeclarationExpressionCollection parametersCollection = new CodeParameterDeclarationExpressionCollection();
parametersCollection.Add( new CodeParameterDeclarationExpression(typeof(int), "testIntArgument") );
parametersCollection.Add( new CodeParameterDeclarationExpression(typeof(bool), "testBoolArgument") );
collection.AddRange( parametersCollection );

// Tests for the presence of a CodeParameterDeclarationExpression  
// in the collection, and retrieves its index if it is found.
CodeParameterDeclarationExpression testParameter = new CodeParameterDeclarationExpression(typeof(int), "testIntArgument");
int itemIndex = -1;
if( collection.Contains( testParameter ) )
    itemIndex = collection.IndexOf( testParameter );

// Copies the contents of the collection beginning at index 0 to the specified CodeParameterDeclarationExpression array. 
// 'parameters' is a CodeParameterDeclarationExpression array.
collection.CopyTo( parameters, 0 );

// Retrieves the count of the items in the collection. 
int collectionCount = collection.Count;

// Inserts a CodeParameterDeclarationExpression at index 0  
// of the collection.
collection.Insert( 0, new CodeParameterDeclarationExpression(typeof(int), "testIntArgument") );

// Removes the specified CodeParameterDeclarationExpression  
// from the collection.
CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(typeof(int), "testIntArgument");
collection.Remove( parameter );

// Removes the CodeParameterDeclarationExpression at index 0.


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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0