Partilhar via


Solution2.Count Property

Definition

Gets a value indicating the number of projects in the solution.

public:
 property int Count { int get(); };
public:
 property int Count { int get(); };
[System.Runtime.InteropServices.DispId(12)]
public int Count { [System.Runtime.InteropServices.DispId(12)] get; }
[<System.Runtime.InteropServices.DispId(12)>]
[<get: System.Runtime.InteropServices.DispId(12)>]
member this.Count : int
Public ReadOnly Property Count As Integer

Property Value

The number of projects in the solution.

Implements

Attributes

Examples

Sub SolutionCountExample(ByVal dte As DTE2)  
    ' Counts the projects in a solution.  
    ' Open a solution in Visual Studio before running this example.  
   Try  
       Dim soln As Solution2 = CType(_applicationObject.Solution, _  
       Solution2)  
        ' List the number of projects.  
        MsgBox("Number of projects in" & soln.FullName & " is: " _  
        & vbCr & soln.Count)  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
//you will need to add this reference to your project as well  
using System.Windows.Forms;  
public void SolutionCount(DTE2 dte)  
{  
    // Count the projects in a solution.  
    // Open a solution in Visual Studio before running this  
    // example.  
    Try  
    {  
        Solution2 soln = (Solution2)_applicationObject.Solution;  
        // List the number of projects.  
        MessageBox.Show("Number of projects in" + soln.FullName   
+ " is: " + "\n" + soln.Count);  
    }  
    catch(SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Applies to