CodeStatementCollection.IndexOf(CodeStatement) Метод

Определение

Получает значение указанного объекта CodeStatement в CodeStatementCollection, если он существует в коллекции.

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

Параметры

value
CodeStatement

Объект CodeStatement для поиска в коллекции.

Возвращаемое значение

Индекс указанного объекта, если найден в коллекции; в противном случае — значение -1.

Примеры

В следующем примере выполняется поиск определенного CodeStatement объекта и используется IndexOf метод для получения значения индекса, по которому он был найден.

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

Применяется к

См. также раздел