Partager via


Item propriété

Retrieves a TaskInfo from the collection.

Espace de noms :  Microsoft.SqlServer.Dts.Runtime
Assembly :  Microsoft.SqlServer.ManagedDTS (dans Microsoft.SqlServer.ManagedDTS.dll)

Syntaxe

'Déclaration
Public ReadOnly Default Property Item ( _
    index As Object _
) As TaskInfo
    Get
'Utilisation
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
JScript prend en charge l'utilisation de propriétés indexées, mais pas la déclaration de nouvelles propriétés.

Paramètres

Valeur de la propriété

Type : Microsoft.SqlServer.Dts.Runtime. . :: . .TaskInfo
The TaskInfo object.

Notes

If the call to the Contains method returns true, you can access the specified element in the collection by using the syntax TaskInfos[index]. However, if the call to Contains method returns false, this property throws an exception. In C#, this property is the indexer for the TaskInfos class.

Exemples

The following code example retrieves an item from the collection using two methods. The first method uses the tInfos[0] syntax to retrieve the entire object located in the first position of the collection and place it in the tInfo object. You can now retrieve all properties from the tInfo object as usual. The second method demonstrates how to retrieve a specific property from the first object in the collection.

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

Sample Output:

The task ID of the first provider is: {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}

The Name of the first task is: Execute Package Task