共用方式為


CodeDirectiveCollection.Contains(CodeDirective) 方法

定義

取得值,指出集合是否包含指定的 CodeDirective 物件。

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

參數

value
CodeDirective

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

傳回

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

範例

下列程式代碼範例示範如何使用 Contains 方法來判斷集合是否包含特定的 CodeDirective 物件。 這個範例是提供給 類別之較大範例的 CodeDirectiveCollection 一部分。

// Tests for the presence of a CodeDirective in the
// collection, and retrieves its index if it is found.
CodeDirective testDirective = new CodeRegionDirective(CodeRegionMode.Start, "Region1");
int itemIndex = -1;
if (collection.Contains(testDirective))
    itemIndex = collection.IndexOf(testDirective);
' Tests for the presence of a CodeDirective in the 
' collection, and retrieves its index if it is found.
Dim testDirective = New CodeRegionDirective(CodeRegionMode.Start, "Region1")
Dim itemIndex As Integer = -1
If collection.Contains(testDirective) Then
    itemIndex = collection.IndexOf(testDirective)
End If

適用於