共用方式為


CodeStatementCollection.Contains(CodeStatement) 方法

定義

取得值,這個值表示集合是否包含指定的 CodeStatement 物件。

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

參數

value
CodeStatement

要在集合中搜尋的 CodeStatement 物件。

傳回

如果集合包含指定的物件,則為 true,否則為 false

範例

下列範例會 Contains 使用 方法來搜尋特定 CodeStatement 是否存在,並擷取找到它的索引值。

// 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 );
// 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 );
' 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

適用於

另請參閱