CodeAttributeArgumentCollection.IndexOf(CodeAttributeArgument) Метод

Определение

Возвращает индекс указанного CodeAttributeArgument объекта в коллекции, если он существует в коллекции.

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

Параметры

value
CodeAttributeArgument

Объект CodeAttributeArgument , который нужно найти в коллекции.

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

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

Примеры

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

// Tests for the presence of a CodeAttributeArgument
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true));
int itemIndex = -1;
if( collection.Contains( testArgument ) )
    itemIndex = collection.IndexOf( testArgument );
' Tests for the presence of a CodeAttributeArgument in 
' the collection, and retrieves its index if it is found.
Dim testArgument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True))
Dim itemIndex As Integer = -1
If collection.Contains(testArgument) Then
    itemIndex = collection.IndexOf(testArgument)
End If

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

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