CodeStatementCollection.IndexOf(CodeStatement) Metod

Definition

Hämtar indexet för det angivna CodeStatement objektet i CodeStatementCollection, om det finns i samlingen.

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

Parametrar

value
CodeStatement

Att CodeStatement hitta i samlingen.

Returer

Indexet för det angivna objektet, om det hittas, i samlingen; annars -1.

Exempel

I följande exempel söker du efter förekomsten av en specifik CodeStatement och använder IndexOf metoden för att hämta indexvärdet som det hittades på.

// Tests for the presence of a CodeStatement in the
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if( collection.Contains( testStatement ) )
    itemIndex = collection.IndexOf( testStatement );
' Tests for the presence of a CodeStatement in the 
' collection, and retrieves its index if it is found.
Dim itemIndex As Integer = -1
If collection.Contains(testStatement) Then
    itemIndex = collection.IndexOf(testStatement)
End If

Gäller för

Se även