CodeCommentStatementCollection.Contains(CodeCommentStatement) 方法

定义

获取一个值,该值指示集合是否包含指定的 CodeCommentStatement 对象。

public:
 bool Contains(System::CodeDom::CodeCommentStatement ^ value);
public bool Contains (System.CodeDom.CodeCommentStatement value);
member this.Contains : System.CodeDom.CodeCommentStatement -> bool
Public Function Contains (value As CodeCommentStatement) As Boolean

参数

value
CodeCommentStatement

要在集合中搜索的 CodeCommentStatement

返回

当集合包含指定的对象时为 true;否则为 false

示例

以下示例使用 Contains 方法搜索是否存在特定 CodeCommentStatement 对象,并获取找到该对象的索引值。

// Tests for the presence of a CodeCommentStatement in the 
// collection, and retrieves its index if it is found.
CodeCommentStatement^ testComment = gcnew CodeCommentStatement( "Test comment" );
int itemIndex = -1;
if ( collection->Contains( testComment ) )
   itemIndex = collection->IndexOf( testComment );
// 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 );
' 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

适用于

另请参阅