CodeTypeDeclarationCollection.IndexOf(CodeTypeDeclaration) 方法

定义

获取指定的 CodeTypeDeclaration 对象在 CodeTypeDeclarationCollection 中的索引(如果它已存在于该集合中)。

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

参数

value
CodeTypeDeclaration

要在集合中查找的 CodeTypeDeclaration

返回

如果在该集合中找到指定对象,则为此对象在该集合中的索引;否则为 –1。

示例

以下示例从 CodeTypeDeclarationCollection 对象中检索CodeTypeDeclaration条目,并显示方法返回IndexOf的名称和索引。

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

适用于

另请参阅