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

适用于