Bewerken

Delen via


CodeNamespaceCollection.IndexOf(CodeNamespace) Method

Definition

Gets the index of the specified CodeNamespace object in the CodeNamespaceCollection, if it exists in the collection.

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

The CodeNamespace to locate.

Returns

The index of the specified CodeNamespace, if it is found, in the collection; otherwise, -1.

Examples

The following example searches for the presence of a specific CodeNamespace and uses the IndexOf method to retrieve the index value at which it was found.

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

Applies to

See also