CodeStatementCollection.Contains(CodeStatement) 方法

定義

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

C#
public bool Contains (System.CodeDom.CodeStatement value);

參數

value
CodeStatement

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

傳回

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

範例

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

C#
// 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 );

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另請參閱