CodeTypeMemberCollection.IndexOf(CodeTypeMember) 方法

定义

获取指定的 CodeTypeMember 在该集合中的索引(如果它在该集合中存在)。

public:
 int IndexOf(System::CodeDom::CodeTypeMember ^ value);
public int IndexOf (System.CodeDom.CodeTypeMember value);
member this.IndexOf : System.CodeDom.CodeTypeMember -> int
Public Function IndexOf (value As CodeTypeMember) As Integer

参数

value
CodeTypeMember

要在集合中查找的 CodeTypeMember

返回

如果在该集合中找到指定对象,则为此对象在该集合中的索引;否则为 -1。

示例

下面的代码示例搜索是否存在特定 CodeTypeMember 对象,并使用 IndexOf 方法检索找到它的索引值。

// 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

适用于

另请参阅