Udostępnij przez


Właściwość TaskInfos.Item

Pobiera TaskInfo z kolekcja.

Przestrzeń nazw:  Microsoft.SqlServer.Dts.Runtime
Zestaw:  Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)

Składnia

'Deklaracja
Public ReadOnly Default Property Item ( _
    index As Object _
) As TaskInfo
    Get
'Użycie
Dim instance As TaskInfos
Dim index As Object
Dim value As TaskInfo

value = instance(index)
public TaskInfo this[
    Object index
] { get; }
public:
property TaskInfo^ default[Object^ index] {
    TaskInfo^ get (Object^ index);
}
member Item : TaskInfo
Język JScript obsługuje używanie indeksowanych właściwości, ale nie obsługuje deklarowania nowych.

Parametry

Wartość właściwości

Typ: Microsoft.SqlServer.Dts.Runtime.TaskInfo
TaskInfo Obiektu.

Uwagi

Jeśli wywołanie Contains Metoda zwraca true, określonego elementu kolekcja można uzyskać dostęp za pomocą składni TaskInfos[index].Jednakże jeśli wywołanie Contains Metoda zwraca false, ta właściwość zgłasza wyjątek.W języku C#, ta właściwość jest indeksowanie dla TaskInfos klasy

Przykłady

Poniższy przykład kodu pobiera element z kolekcja, używając dwóch metod.Pierwszy metoda używa tInfos[0] składni, aby pobrać cały obiekt znajdujący się na pierwszym miejscu gromadzenia i umieścić go w tInfo obiektu.Można teraz pobrać wszystkie właściwości z tInfo obiektu w zwykły sposób.Druga metoda ilustruje sposób pobrać właściwość określonym pierwszy obiekt kolekcja.

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

Przykładowe dane wyjściowe:

Identyfikator zadania pierwszego dostawca jest: {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}

Nazwa pierwszego zadania jest: Wykonywanie zadań pakietu