Share via


CodeTypeMemberCollection.IndexOf(CodeTypeMember) Método

Definição

Obterá o índice na coleção do CodeTypeMember especificado, se ele existir na coleção.

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

Parâmetros

value
CodeTypeMember

O CodeTypeMember a ser localizado na coleção.

Retornos

O índice na coleção do objeto especificado, se encontrado; caso contrário, -1.

Exemplos

O exemplo de código a seguir pesquisa a presença de um objeto específico CodeTypeMember e usa o IndexOf método para recuperar o valor de índice no qual ele foi encontrado.

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

Aplica-se a

Confira também