CodeAttributeDeclarationCollection.IndexOf(CodeAttributeDeclaration) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合中指定 CodeAttributeDeclaration 物件的索引,前提是該物件存在於集合中。
public:
int IndexOf(System::CodeDom::CodeAttributeDeclaration ^ value);
public int IndexOf(System.CodeDom.CodeAttributeDeclaration value);
member this.IndexOf : System.CodeDom.CodeAttributeDeclaration -> int
Public Function IndexOf (value As CodeAttributeDeclaration) As Integer
參數
- value
- CodeAttributeDeclaration
CodeAttributeDeclaration要在收藏中找到的物件。
傳回
若找到指定物件集合中的索引;否則,為負1。
範例
以下範例搜尋特定 CodeAttributeDeclaration 實例的存在,並使用此 IndexOf 方法取得該實例被發現的索引值。
// Tests for the presence of a CodeAttributeDeclaration in
// the collection, and retrieves its index if it is found.
CodeAttributeDeclaration testdeclaration = new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description")) );
int itemIndex = -1;
if( collection.Contains( testdeclaration ) )
itemIndex = collection.IndexOf( testdeclaration );
' Tests for the presence of a CodeAttributeDeclaration in the
' collection, and retrieves its index if it is found.
Dim testdeclaration As New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description")))
Dim itemIndex As Integer = -1
If collection.Contains(testdeclaration) Then
itemIndex = collection.IndexOf(testdeclaration)
End If