CodeCommentStatementCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a collection of CodeCommentStatement objects.
public ref class CodeCommentStatementCollection : System::Collections::CollectionBase
public class CodeCommentStatementCollection : System.Collections.CollectionBase
type CodeCommentStatementCollection = class
inherit CollectionBase
Public Class CodeCommentStatementCollection
Inherits CollectionBase
- Inheritance
Examples
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.
Dim collection As New CodeCommentStatementCollection()
' Adds a CodeCommentStatement to the collection.
collection.Add(New CodeCommentStatement("Test comment"))
' Adds an array of CodeCommentStatement objects to the collection.
Dim comments As CodeCommentStatement() = {New CodeCommentStatement("Test comment"), New CodeCommentStatement("Another test comment")}
collection.AddRange(comments)
' Adds a collection of CodeCommentStatement objects to the
' collection.
Dim commentsCollection As 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.
Dim testComment As New CodeCommentStatement("Test comment")
Dim itemIndex As Integer = -1
If collection.Contains(testComment) Then
itemIndex = collection.IndexOf(testComment)
End If
' 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.
Dim collectionCount As Integer = 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.
Dim comment As New CodeCommentStatement("Test comment")
collection.Remove(comment)
' Removes the CodeCommentStatement at index 0.
collection.RemoveAt(0)
Remarks
The CodeCommentStatementCollection class provides a simple collection object that can be used to store a set of CodeCommentStatement objects.
Constructors
| Name | Description |
|---|---|
| CodeCommentStatementCollection() |
Initializes a new instance of the CodeCommentStatementCollection class. |
| CodeCommentStatementCollection(CodeCommentStatement[]) |
Initializes a new instance of the CodeCommentStatementCollection class containing the specified array of CodeCommentStatement objects. |
| CodeCommentStatementCollection(CodeCommentStatementCollection) |
Initializes a new instance of the CodeCommentStatementCollection class containing the elements of the specified source collection. |
Properties
| Name | Description |
|---|---|
| Item[Int32] |
Gets or sets the CodeCommentStatement object at the specified index in the collection. |
Methods
| Name | Description |
|---|---|
| Add(CodeCommentStatement) |
Adds the specified CodeCommentStatement object to the collection. |
| AddRange(CodeCommentStatement[]) |
Copies the elements of the specified CodeCommentStatement array to the end of the collection. |
| AddRange(CodeCommentStatementCollection) |
Copies the contents of another CodeCommentStatementCollection object to the end of the collection. |
| Contains(CodeCommentStatement) |
Gets a value that indicates whether the collection contains the specified CodeCommentStatement object. |
| CopyTo(CodeCommentStatement[], Int32) |
Copies the collection objects to the specified one-dimensional Array beginning at the specified index. |
| IndexOf(CodeCommentStatement) |
Gets the index of the specified CodeCommentStatement object in the collection, if it exists in the collection. |
| Insert(Int32, CodeCommentStatement) |
Inserts a CodeCommentStatement object into the collection at the specified index. |
| Remove(CodeCommentStatement) |
Removes the specified CodeCommentStatement object from the collection. |