共用方式為


CodeTypeMemberCollection.Contains(CodeTypeMember) 方法

定義

取得值,表示集合是否包含指定的 CodeTypeMember

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

參數

value
CodeTypeMember

要在集合中搜尋的 CodeTypeMember

傳回

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

範例

下列程式代碼範例會 Contains 使用 方法來搜尋特定 CodeTypeMember 物件是否存在,並擷取找到它的索引值。

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

適用於

另請參閱