CodeNamespaceCollection.IndexOf(CodeNamespace) Método

Definición

Obtiene el índice del objeto CodeNamespace especificado en CodeNamespaceCollection si existe en la colección.

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

Parámetros

value
CodeNamespace

Clase CodeNamespace que se va a localizar.

Devoluciones

Índice de objeto CodeNamespace especificado, si se encuentra en la colección; en caso contrario, -1.

Ejemplos

En el ejemplo siguiente se busca la presencia de un elemento específico CodeNamespace y se usa el IndexOf método para recuperar el valor de índice en el que se encontró.

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

Se aplica a

Consulte también