TaskInfos.Item[Object] 속성

정의

컬렉션에서 TaskInfo를 검색합니다.

public:
 property Microsoft::SqlServer::Dts::Runtime::TaskInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::TaskInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.TaskInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.TaskInfo
Default Public ReadOnly Property Item(index As Object) As TaskInfo

매개 변수

index
Object

컬렉션에서 검색할 TaskInfo의 이름, ID 또는 인덱스입니다.

속성 값

TaskInfo 개체

예제

다음 코드 예제에서는 두 가지 메서드를 사용 하 여 컬렉션에서 항목을 검색 합니다. 첫 번째 메서드는 구문을 사용하여 tInfos[0] 컬렉션의 첫 번째 위치에 있는 전체 개체를 검색하고 개체에 tInfo 배치합니다. 이제 평소와 같이 개체에서 모든 속성을 검색할 tInfo 수 있습니다. 두 번째 메서드는 컬렉션의 첫 번째 개체에서 특정 속성을 검색하는 방법을 보여 줍니다.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace TaskInfos_Item  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application app = new Application();  
            TaskInfos tInfos = app.TaskInfos;  

            //Using the Item method syntax of [x], obtain the first   
            //entry.  
            TaskInfo tInfo = tInfos[0];  
            String nameOfFirstItem = tInfos[0].Name;  
           //This could also be done using the Name property, as  
           //demonstrated by this next line of commented code.  
           //TaskInfo tInfo = tInfos["Execute Package Task"];  
           //You can also use the ID property.  
           // TaskInfo tInfo = tInfos["{8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}"];  

            //Print the name of the task object located at position [0].  
            Console.WriteLine("The task ID of the first provider is: {0}", tInfo.ID);  
            Console.WriteLine("The Name of the first task is: {0}", nameOfFirstItem);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace TaskInfos_Item  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   
            Dim tInfos As TaskInfos =  app.TaskInfos   

            'Using the Item method syntax of [x], obtain the first   
            'entry.  
            Dim tInfo As TaskInfo =  tInfos(0)   
            Dim nameOfFirstItem As String =  tInfos(0).Name   
           'This could also be done using the Name property, as  
           'demonstrated by this next line of commented code.  
           'TaskInfo tInfo = tInfos["Execute Package Task"];  
           'You can also use the ID property.  
           ' TaskInfo tInfo = tInfos["{8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}"];  

            'Print the name of the task object located at position [0].  
            Console.WriteLine("The task ID of the first provider is: {0}", tInfo.ID)  
            Console.WriteLine("The Name of the first task is: {0}", nameOfFirstItem)  
        End Sub  
    End Class  
End Namespace  

샘플 출력:

첫 번째 공급자의 작업 ID는 {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}입니다.

첫 번째 작업의 이름은 패키지 실행 태스크입니다.

설명

메서드 호출이 Contains 반환 true되는 경우 구문을 TaskInfos[index]사용하여 컬렉션에서 지정된 요소에 액세스할 수 있습니다. 그러나 메서드 호출 Contains 이 반환 false되면 이 속성은 예외를 throw합니다. C#에서 이 속성은 TaskInfos 클래스의 인덱서입니다.

적용 대상