CodeCatchClauseCollection.IndexOf(CodeCatchClause) Метод

Определение

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

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

Параметры

value
CodeCatchClause

Объект CodeCatchClause, который требуется найти в коллекции.

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

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

Примеры

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

// Tests for the presence of a CodeCatchClause in the 
// collection, and retrieves its index if it is found.
CodeCatchClause^ testClause = gcnew CodeCatchClause( "e" );
int itemIndex = -1;
if ( collection->Contains( testClause ) )
   itemIndex = collection->IndexOf( testClause );
// Tests for the presence of a CodeCatchClause in the
// collection, and retrieves its index if it is found.
CodeCatchClause testClause = new CodeCatchClause("e");
int itemIndex = -1;
if( collection.Contains( testClause ) )
    itemIndex = collection.IndexOf( testClause );
' Tests for the presence of a CodeCatchClause in the 
' collection, and retrieves its index if it is found.
Dim testClause As New CodeCatchClause("e")
Dim itemIndex As Integer = -1
If collection.Contains(testClause) Then
    itemIndex = collection.IndexOf(testClause)
End If

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

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