Solution3.Item(Object) Método

Definição

Retorna um membro indexado de uma Projects coleção.

public:
 EnvDTE::Project ^ Item(System::Object ^ index);
public:
 EnvDTE::Project ^ Item(Platform::Object ^ index);
EnvDTE::Project Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.Project Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> EnvDTE.Project
Public Function Item (index As Object) As Project

Parâmetros

index
Object

Retornos

Project

Um objeto Project.

Implementações

Atributos

Exemplos

Sub SolnItemExample(ByVal dte As DTE2)  
    ' Iterates through project items in a  solution.  
    ' Make sure you have a solution open in Visual Studio before running this example.  
    Try  
        Dim soln As Solution3 = _  
        CType(_applicationObject.Solution, Solution3)  
        ' Dim solnName As String = _  
         System.IO.Path.GetFileNameWithoutExtension(soln.FullName)  
        Dim tempString As String = "The items in the solution are: "  _  
        & vbCr  
        For i As Integer = 1 To soln.Projects.Count  
            tempString = tempString & soln.Item(i).Name.ToString()  _  
            & vbCr  
        Next  
        MsgBox(tempString)  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
using System.Windows.Forms;  
public void SolnItemExample(DTE2 dte)  
{  
    // Iterates through the project items in a solution.  
    // Open a solution in Visual Studio before running this example.  
    try  
    {  
        Solution3 soln = (Solution3)_applicationObject.Solution;  
        String tempString = "The items in the solution are: " + "\n";  
        for (int i = 1; i <= soln.Projects.Count; i++)  
        {  
            tempString = tempString + soln.Item(i).Name.ToString()   
              + "\n";  
        }  
        MessageBox.Show(tempString);  
    }  
    catch (SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Comentários

O valor passado para Index é um inteiro que é um índice de um objeto em sua coleção. O valor de Index também pode ser um valor de cadeia de caracteres que é igual a um objeto na coleção. O valor exato aceito pelo, no Item entanto, depende da coleção e de sua implementação.

O Item método lançará uma ArgumentException exceção se a coleção não conseguir localizar o objeto que corresponde ao valor do índice.

Aplica-se a