다음을 통해 공유


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 예외를 throw합니다.

예제

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 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행