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)

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeParameterDeclarationExpressionCollection _
	Inherits CollectionBase
'Usage
Dim instance As CodeParameterDeclarationExpressionCollection

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. 
Dim collection As New CodeParameterDeclarationExpressionCollection()

' Adds a CodeParameterDeclarationExpression to the collection.
collection.Add(New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument"))

' Adds an array of CodeParameterDeclarationExpression objects  
' to the collection. 
Dim parameters As CodeParameterDeclarationExpression() = {New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument"), New CodeParameterDeclarationExpression(GetType(Boolean), "testBoolArgument")}
collection.AddRange(parameters)

' Adds a collection of CodeParameterDeclarationExpression  
' objects to the collection. 
Dim parametersCollection As New CodeParameterDeclarationExpressionCollection()
parametersCollection.Add(New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument"))
parametersCollection.Add(New CodeParameterDeclarationExpression(GetType(Boolean), "testBoolArgument"))
collection.AddRange(parametersCollection)

' Tests for the presence of a CodeParameterDeclarationExpression  
' in the collection, and retrieves its index if it is found. 
Dim testParameter As New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument")
Dim itemIndex As Integer = -1
If collection.Contains(testParameter) Then
    itemIndex = collection.IndexOf(testParameter)
End If 

' 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. 
Dim collectionCount As Integer = collection.Count

' Inserts a CodeParameterDeclarationExpression at index 0  
' of the collection.
collection.Insert(0, New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument"))

' Removes the specified CodeParameterDeclarationExpression  
' from the collection. 
Dim parameter As New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument")
collection.Remove(parameter)

' Removes the CodeParameterDeclarationExpression at index 0.
collection.RemoveAt(0)

System.Object
  System.Collections.CollectionBase
    System.CodeDom.CodeParameterDeclarationExpressionCollection

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
Show: