CodeTypeDeclarationCollection.IndexOf(CodeTypeDeclaration) Méthode

Définition

Obtient l'index de l'objet CodeTypeDeclaration spécifié dans la CodeTypeDeclarationCollection, s'il existe dans la collection.

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

Paramètres

value
CodeTypeDeclaration

CodeTypeDeclaration à rechercher dans la collection.

Retours

Index de l'objet spécifié, s'il existe, dans la collection ; sinon, -1.

Exemples

L’exemple suivant récupère les CodeTypeDeclaration entrées d’un CodeTypeDeclarationCollection objet et affiche leurs noms et index retournés par la IndexOf méthode.

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

S’applique à

Voir aussi