Solution4.Item(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回 Projects 集合的一个索引成员。
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
参数
- index
- Object
返回
Project 对象。
实现
- 属性
示例
Sub SolnItemExample(ByVal dte As DTE2)
' Iterate through project items in a solution.
' Make sure you have a solution open in Visual
' Studio before running this example.
Try
Dim soln As Solution4 = _
CType(_applicationObject.Solution, Solution4)
' 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)
{
// Iterate through the project items in a solution.
// Open a solution in Visual Studio before running
// this example.
try
{
Solution4 soln = (Solution4)_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);
}
}
注解
传递给的值 Index 是一个整数,它是其集合中对象的索引。 的值 Index 还可以是等同于集合中的对象的字符串值。 但接受的确切值 Item 取决于集合及其实现。
Item ArgumentException 如果集合找不到与索引值对应的对象,则该方法将引发异常。