CodeAttributeArgumentCollection.IndexOf(CodeAttributeArgument) Methode

Definitie

Hiermee haalt u de index op van het opgegeven CodeAttributeArgument object in de verzameling, als het in de verzameling bestaat.

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

Parameters

value
CodeAttributeArgument

Het CodeAttributeArgument object dat in de verzameling moet worden gevonden.

Retouren

De index van het opgegeven object, indien gevonden, in de verzameling; anders, -1.

Voorbeelden

In het volgende voorbeeld wordt gezocht naar de aanwezigheid van een specifiek CodeAttributeArgument object en wordt de IndexOf methode gebruikt om de indexwaarde op te halen waarop het is gevonden.

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

Van toepassing op

Zie ook