共用方式為


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

適用於

另請參閱