CodeNamespaceCollection.Contains(CodeNamespace) 方法

定义

获取一个值,该值指示集合是否包含指定的 CodeNamespace 对象。

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

参数

value
CodeNamespace

要在集合中搜索的 CodeNamespace

返回

如果 CodeNamespace 包含在集合中,则为 true;否则为 false

示例

以下示例使用 Contains 方法在 中CodeNamespaceCollection查找 CodeNamespace 对象。

// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace^ testNamespace = gcnew CodeNamespace( "TestNamespace" );
int itemIndex = -1;
if ( collection->Contains( testNamespace ) )
   itemIndex = collection->IndexOf( testNamespace );
// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace testNamespace = new CodeNamespace("TestNamespace");
int itemIndex = -1;
if( collection.Contains( testNamespace ) )
    itemIndex = collection.IndexOf( testNamespace );
' Tests for the presence of a CodeNamespace in the collection,
' and retrieves its index if it is found.
Dim testNamespace As New CodeNamespace("TestNamespace")
Dim itemIndex As Integer = -1
If collection.Contains(testNamespace) Then
    itemIndex = collection.IndexOf(testNamespace)
End If

适用于

另请参阅