CodeCommentStatementCollection Class
.NET Framework 3.0
Represents a collection of CodeCommentStatement objects.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Assembly: System (in system.dll)
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class CodeCommentStatementCollection : CollectionBase
/** @attribute SerializableAttribute() */ /** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class CodeCommentStatementCollection extends CollectionBase
SerializableAttribute ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class CodeCommentStatementCollection extends CollectionBase
Not applicable.
The following example demonstrates the use of the CodeCommentStatementCollection 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 CodeCommentStatementCollection. CodeCommentStatementCollection collection = new CodeCommentStatementCollection(); // Adds a CodeCommentStatement to the collection. collection.Add( new CodeCommentStatement("Test comment") ); // Adds an array of CodeCommentStatement objects to the collection. CodeCommentStatement[] comments = { new CodeCommentStatement("Test comment"), new CodeCommentStatement("Another test comment") }; collection.AddRange( comments ); // Adds a collection of CodeCommentStatement objects to the collection. CodeCommentStatementCollection commentsCollection = new CodeCommentStatementCollection(); commentsCollection.Add( new CodeCommentStatement("Test comment") ); commentsCollection.Add( new CodeCommentStatement("Another test comment") ); collection.AddRange( commentsCollection ); // Tests for the presence of a CodeCommentStatement in the // collection, and retrieves its index if it is found. CodeCommentStatement testComment = new CodeCommentStatement("Test comment"); int itemIndex = -1; if( collection.Contains( testComment ) ) itemIndex = collection.IndexOf( testComment ); // Copies the contents of the collection, beginning at index 0, // to the specified CodeCommentStatement array. // 'comments' is a CodeCommentStatement array. collection.CopyTo( comments, 0 ); // Retrieves the count of the items in the collection. int collectionCount = collection.Count; // Inserts a CodeCommentStatement at index 0 of the collection. collection.Insert( 0, new CodeCommentStatement("Test comment") ); // Removes the specified CodeCommentStatement from the collection. CodeCommentStatement comment = new CodeCommentStatement("Test comment"); collection.Remove( comment ); // Removes the CodeCommentStatement at index 0. collection.RemoveAt(0);
// Creates an empty CodeCommentStatementCollection.
CodeCommentStatementCollection collection = new
CodeCommentStatementCollection();
// Adds a CodeCommentStatement to the collection.
collection.Add(new CodeCommentStatement("Test comment"));
// Adds an array of CodeCommentStatement objects to the collection.
CodeCommentStatement comments[] = { new CodeCommentStatement(
"Test comment"), new CodeCommentStatement("Another test comment") };
collection.AddRange(comments);
// Adds a collection of CodeCommentStatement objects to the collection.
CodeCommentStatementCollection commentsCollection = new
CodeCommentStatementCollection();
commentsCollection.Add(new CodeCommentStatement("Test comment"));
commentsCollection.Add(new CodeCommentStatement("Another test comment"));
collection.AddRange(commentsCollection);
// Tests for the presence of a CodeCommentStatement in the
// collection, and retrieves its index if it is found.
CodeCommentStatement testComment = new
CodeCommentStatement("Test comment");
int itemIndex = -1;
if (collection.Contains(testComment)) {
itemIndex = collection.IndexOf(testComment);
}
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeCommentStatement array.
// 'comments' is a CodeCommentStatement array.
collection.CopyTo(comments, 0);
// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();
// Inserts a CodeCommentStatement at index 0 of the collection.
collection.Insert(0, new CodeCommentStatement("Test comment"));
// Removes the specified CodeCommentStatement from the collection.
CodeCommentStatement comment = new CodeCommentStatement("Test comment");
collection.Remove(comment);
// Removes the CodeCommentStatement 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: