Partager via


Projects.Item, méthode

Retourne un membre indexé d'une collection Projects.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
Function Item ( _
    index As Object _
) As Project
Project Item(
    Object index
)
Project^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> Project 
function Item(
    index : Object
) : Project

Paramètres

  • index
    Type : System.Object
    Obligatoire.L'index de l'élément à retourner.

Valeur de retour

Type : EnvDTE.Project
Objet Project.

Notes

La valeur passée à index est un entier qui représente l'index d'un objet Project de sa collection. La valeur de index peut également être une valeur de chaîne qui équivaut au nom d'un projet dans la collection.

La méthode Item lève une exception ArgumentException si la collection ne peut pas trouver l'objet correspondant à la valeur d'index.

Exemples

public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a project before running this sample
        Projects prjs = dte.Solution.Projects;
        string msg = "There are " + prjs.Count.ToString() + " projects in this collection.";
        msg += "\nThe application containing this Projects collection: " + prjs.DTE.Name;
        msg += "\nThe parent object of the Projects collection: " + prjs.Parent.Name;
        msg += "\nThe GUID representing the Projects type: " + prjs.Kind;
        if (prjs.Properties != null)
        {
            msg += "\nProperties:";
            foreach (Property prop in prjs.Properties)
            {
                msg += "\n   " + prop.Name;
            }
        }
        MessageBox.Show(msg, "Projects Collection");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Sécurité .NET Framework

Voir aussi

Référence

Projects Interface

EnvDTE, espace de noms

Autres ressources

Comment : compiler et exécuter les exemples de code du modèle objet Automation