共用方式為


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

適用於

另請參閱