Share via


CodeNamespaceCollection.IndexOf(CodeNamespace) Methode

Definition

Ruft den Index des angegebenen CodeNamespace-Objekts in der CodeNamespaceCollection ab, sofern dieses in der Auflistung vorhanden ist.

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

Parameter

value
CodeNamespace

Die zu suchende CodeNamespace.

Gibt zurück

Der Index des angegebenen CodeNamespace, wenn dieser in der Auflistung gefunden wird, andernfalls -1.

Beispiele

Im folgenden Beispiel wird nach dem Vorhandensein eines bestimmten CodeNamespace gesucht und die IndexOf -Methode verwendet, um den Indexwert abzurufen, an dem er gefunden wurde.

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

Gilt für:

Weitere Informationen