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

適用於

另請參閱