Linguaggio

TaskInfos.Item[Object] Proprietà

Definizione

Recupera un TaskInfo dalla collezione.

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

Parametri

index
Object

Il nome, l'ID o l'indice da TaskInfo recuperare dalla collezione.

Valore della proprietà

Oggetto TaskInfo.

Esempio

Il seguente esempio di codice recupera un elemento dalla collezione utilizzando due metodi. Il primo metodo utilizza la tInfos[0] sintassi per recuperare l'intero oggetto situato nella prima posizione della collezione e inserirlo nell'oggetto tInfo . Ora puoi recuperare tutte le proprietà dall'oggetto tInfo come al solito. Il secondo metodo dimostra come recuperare una proprietà specifica dal primo oggetto della collezione.

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  

Output di esempio:

L'ID del compito del primo fornitore è: {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}

Il nome del primo compito è: Esegui il Pacchetto Compito

Commenti

Se la chiamata al Contains metodo restituisce true, puoi accedere all'elemento specificato nella collezione usando la sintassi TaskInfos[index]. Tuttavia, se la chiamata al Contains metodo restituisce false, questa proprietà lancia un'eccezione. In C# questa proprietà è l'indicizzatore per la TaskInfos classe .

Si applica a