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

适用于

另请参阅