Export (0) Print
Expand All

CodeExpressionCollection Class

Represents a collection of CodeExpression objects.

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

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

Provides a simple collection object that can represent a set of CodeDOM expression objects.

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

// Creates an empty CodeExpressionCollection.
CodeExpressionCollection collection = new CodeExpressionCollection();

// Adds a CodeExpression to the collection.
collection.Add( new CodePrimitiveExpression(true) );

// Adds an array of CodeExpression objects to the collection.
CodeExpression[] expressions = { new CodePrimitiveExpression(true), new CodePrimitiveExpression(true) };
collection.AddRange( expressions );

// Adds a collection of CodeExpression objects to the collection.
CodeExpressionCollection expressionsCollection = new CodeExpressionCollection();
expressionsCollection.Add( new CodePrimitiveExpression(true) );
expressionsCollection.Add( new CodePrimitiveExpression(true) );
collection.AddRange( expressionsCollection );

// Tests for the presence of a CodeExpression in the 
// collection, and retrieves its index if it is found.
CodeExpression testComment = new CodePrimitiveExpression(true);
int itemIndex = -1;
if( collection.Contains( testComment ) )
    itemIndex = collection.IndexOf( testComment );

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

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

// Inserts a CodeExpression at index 0 of the collection.
collection.Insert( 0, new CodePrimitiveExpression(true) );

// Removes the specified CodeExpression from the collection.
CodeExpression expression = new CodePrimitiveExpression(true);
collection.Remove( expression );

// Removes the CodeExpression at index 0.
collection.RemoveAt(0);

// Creates an empty CodeExpressionCollection.
CodeExpressionCollection collection = new CodeExpressionCollection();

// Adds a CodeExpression to the collection.
collection.Add(new CodePrimitiveExpression(
    System.Convert.ToString(true)));

// Adds an array of CodeExpression objects to the collection.
CodeExpression expressions[] =  { new CodePrimitiveExpression(
    System.Convert.ToString(true)), new CodePrimitiveExpression(
    System.Convert.ToString(true)) };
collection.AddRange(expressions);
// Adds a collection of CodeExpression objects to the collection.
CodeExpressionCollection expressionsCollection = new 
    CodeExpressionCollection();
expressionsCollection.Add(new CodePrimitiveExpression(
    System.Convert.ToString(true)));
expressionsCollection.Add(new CodePrimitiveExpression(
    System.Convert.ToString(true)));
collection.AddRange(expressionsCollection);

// Tests for the presence of a CodeExpression in the 
// collection, and retrieves its index if it is found.
CodeExpression testComment = new CodePrimitiveExpression(System.
    Convert.ToString(true));
int itemIndex = -1;
if (collection.Contains(testComment)) {
    itemIndex = collection.IndexOf(testComment);
}

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

// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();

// Inserts a CodeExpression at index 0 of the collection.
collection.Insert(0, new CodePrimitiveExpression(System.Convert.
    ToString(true)));

// Removes the specified CodeExpression from the collection.
CodeExpression expression = new CodePrimitiveExpression(System.Convert.
    ToString(true));
collection.Remove(expression);

// Removes the CodeExpression at index 0.
collection.RemoveAt(0);

System.Object
   System.Collections.CollectionBase
    System.CodeDom.CodeExpressionCollection

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