CodeParameterDeclarationExpressionCollection Class
.NET Framework 3.0
Represents a collection of CodeParameterDeclarationExpression objects.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Assembly: System (in system.dll)
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeParameterDeclarationExpressionCollection : CollectionBase
/** @attribute SerializableAttribute() */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ /** @attribute ComVisibleAttribute(true) */ public class CodeParameterDeclarationExpressionCollection extends CollectionBase
SerializableAttribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) ComVisibleAttribute(true) public class CodeParameterDeclarationExpressionCollection extends CollectionBase
Not applicable.
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. collection.RemoveAt(0);
// Creates an empty CodeParameterDeclarationExpressionCollection.
CodeParameterDeclarationExpressionCollection collection = new
CodeParameterDeclarationExpressionCollection();
// Adds a CodeParameterDeclarationExpression to the collection.
collection.Add(new CodeParameterDeclarationExpression(int.class.ToType(),
"testIntArgument"));
// Adds an array of CodeParameterDeclarationExpression objects
// to the collection.
CodeParameterDeclarationExpression parameters[] = { new
CodeParameterDeclarationExpression(int.class.ToType(),
"testIntArgument"), new CodeParameterDeclarationExpression(
boolean.class.ToType(), "testBoolArgument") };
collection.AddRange(parameters);
// Adds a collection of CodeParameterDeclarationExpression objects
// to the collection.
CodeParameterDeclarationExpressionCollection parametersCollection = new
CodeParameterDeclarationExpressionCollection();
parametersCollection.Add(new CodeParameterDeclarationExpression(int.
class.ToType(), "testIntArgument"));
parametersCollection.Add(new CodeParameterDeclarationExpression(boolean.
class.ToType(), "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(int.class.ToType(),
"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.get_Count();
// Inserts a CodeParameterDeclarationExpression at index 0
// of the collection.
collection.Insert(0, new CodeParameterDeclarationExpression(int.
class.ToType(), "testIntArgument"));
// Removes the specified CodeParameterDeclarationExpression
// from the collection.
CodeParameterDeclarationExpression parameter = new
CodeParameterDeclarationExpression(int.class.ToType(),
"testIntArgument");
collection.Remove(parameter);
// Removes the CodeParameterDeclarationExpression at index 0.
collection.RemoveAt(0);
} //CodeParameterDeclarationExpressionCollectionExample
} //Class1
System.Object
System.Collections.CollectionBase
System.CodeDom.CodeParameterDeclarationExpressionCollection
System.Collections.CollectionBase
System.CodeDom.CodeParameterDeclarationExpressionCollection
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.Community Additions
ADD
Show: