CodeNamespaceCollection.IndexOf(CodeNamespace) Methode

Definitie

Hiermee haalt u de index op van het opgegeven CodeNamespace object in de CodeNamespaceCollectionverzameling, als het in de verzameling bestaat.

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

Parameters

value
CodeNamespace

De CodeNamespace te vinden.

Retouren

De index van de opgegeven CodeNamespace, als deze wordt gevonden, in de verzameling; anders -1.

Voorbeelden

In het volgende voorbeeld wordt gezocht naar de aanwezigheid van een specifieke CodeNamespace waarde en wordt de IndexOf methode gebruikt om de indexwaarde op te halen waarop deze is gevonden.

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

Van toepassing op

Zie ook