Sprache

TaskInfos.Item[Object] Eigenschaft

Definition

Ruft eine TaskInfo aus der Sammlung ab.

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

Parameter

index
Object

Der Name, die ID oder der Index des TaskInfo zu abrufenden Namens aus der Sammlung.

Eigenschaftswert

Das TaskInfo-Objekt.

Beispiele

Das folgende Codebeispiel ruft ein Element aus der Sammlung mit zwei Methoden ab. Die erste Methode verwendet die Syntax tInfos[0] , um das gesamte Objekt an der ersten Position der Sammlung abzurufen und im tInfo Objekt zu platzieren. Du kannst jetzt wie üblich alle Eigenschaften aus dem tInfo Objekt abrufen. Die zweite Methode zeigt, wie man eine bestimmte Eigenschaft aus dem ersten Objekt der Sammlung abruft.

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  

Beispielausgabe:

Die Aufgaben-ID des ersten Anbieters lautet: {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}

Der Name der ersten Aufgabe lautet: Paket ausführen Aufgabe

Hinweise

Wenn der Aufruf der Methode Contains zurückkehrt true, können Sie über die Syntax TaskInfos[index]auf das angegebene Element in der Sammlung zugreifen. Wenn jedoch die Aufruf-zu-Methode Contains zurückkehrt false, wirft diese Eigenschaft eine Ausnahme aus. In C# ist diese Eigenschaft der Indexer für die TaskInfos Klasse.

Gilt für: