TaskInfos.Item[Object] 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从集合中检索 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
	参数
属性值
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,则此属性将引发异常。 在 C# 中,此属性是 TaskInfos 类的索引器。