CodeStatementCollection Class
.NET Framework 2.0
Represents a collection of CodeStatement objects.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Assembly: System (in system.dll)
'Declaration <SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeStatementCollection Inherits CollectionBase 'Usage Dim instance As CodeStatementCollection
/** @attribute SerializableAttribute() */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ /** @attribute ComVisibleAttribute(true) */ public class CodeStatementCollection extends CollectionBase
SerializableAttribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) ComVisibleAttribute(true) public class CodeStatementCollection extends CollectionBase
Not applicable.
' Creates an empty CodeStatementCollection. Dim collection As New CodeStatementCollection ' Adds a CodeStatement to the collection. collection.Add(New CodeCommentStatement("Test comment statement")) ' Adds an array of CodeStatement objects to the collection. Dim statements As CodeStatement() = {New CodeCommentStatement("Test comment statement"), New CodeCommentStatement("Test comment statement")} collection.AddRange(statements) ' Adds a collection of CodeStatement objects to the collection. Dim testStatement As New CodeStatement Dim statementsCollection As New CodeStatementCollection statementsCollection.Add(New CodeCommentStatement("Test comment statement")) statementsCollection.Add(New CodeCommentStatement("Test comment statement")) statementsCollection.Add(testStatement) collection.AddRange(statementsCollection) ' Tests for the presence of a CodeStatement in the ' collection, and retrieves its index if it is found. Dim itemIndex As Integer = -1 If collection.Contains(testStatement) Then itemIndex = collection.IndexOf(testStatement) End If ' Copies the contents of the collection beginning at index 0 to the specified CodeStatement array. ' 'statements' is a CodeStatement array. Dim statementArray(collection.Count) As CodeStatement collection.CopyTo(statementArray, 0) ' Retrieves the count of the items in the collection. Dim collectionCount As Integer = collection.Count ' Inserts a CodeStatement at index 0 of the collection. collection.Insert(0, New CodeCommentStatement("Test comment statement")) ' Removes the specified CodeStatement from the collection. collection.Remove(testStatement) ' Removes the CodeStatement at index 0. collection.RemoveAt(0)
// Creates an empty CodeStatementCollection.
CodeStatementCollection collection = new CodeStatementCollection();
// Adds a CodeStatement to the collection.
collection.Add( new CodeCommentStatement("Test comment statement") );
// Adds an array of CodeStatement objects to the collection.
CodeStatement[] statements =
{
new CodeCommentStatement("Test comment statement"),
new CodeCommentStatement("Test comment statement")};
collection.AddRange( statements );
// Adds a collection of CodeStatement objects to the collection.
CodeStatement testStatement = new CodeCommentStatement("Test comment statement");
CodeStatementCollection statementsCollection = new CodeStatementCollection();
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( testStatement );
collection.AddRange( statementsCollection );
// Tests for the presence of a CodeStatement in the
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if( collection.Contains( testStatement ) )
itemIndex = collection.IndexOf( testStatement );
// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
CodeStatement[] statementArray = new CodeStatement[collection.get_Count()];
collection.CopyTo( statementArray, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();
// Inserts a CodeStatement at index 0 of the collection.
collection.Insert( 0, new CodeCommentStatement("Test comment statement") );
// Removes the specified CodeStatement from the collection.
collection.Remove( testStatement );
// Removes the CodeStatement at index 0.
collection.RemoveAt(0);
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: