CodeTypeDeclarationCollection.Contains(CodeTypeDeclaration) 方法

定义

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

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

参数

value
CodeTypeDeclaration

要在此集合中搜索的 CodeTypeDeclaration 对象。

返回

当集合包含指定的对象时为 true;否则为 false

示例

以下示例演示如何使用 Contains 方法在 中CodeTypeDeclarationCollection查找 CodeTypeDeclaration 对象。

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

适用于

另请参阅