Projects.Item 方法

返回 Projects 集合的一个索引成员。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
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

参数

  • index
    类型:Object

    必选。 要返回的项的索引。

返回值

类型:EnvDTE.Project
一个 Project 对象。

备注

传递到 index 的值是一个整数,该整数是 Project 对象在其集合中的索引。 index 的值还可以是一个字符串值,该字符串值表示集合中某个项目的名称。

如果集合找不到对应于索引值的对象,则 Item 方法引发 ArgumentException 异常。

示例

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);
    }
}

.NET Framework 安全性

请参阅

参考

Projects 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例