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
範例輸出:
第一個提供者的工作識別碼是: {8FE4A9F8-D077-436B-9B00-C1EEAEFAFE55}
第一個工作的名稱為:執行封裝工作
備註
如果對方法的呼叫傳回 Contains true ,您可以使用語法來存取集合中的指定元素 TaskInfos[index] 。 不過,如果對方法的呼叫傳回 Contains ,則這個屬性會擲回 false 例外狀況。 在 C# 中,這個屬性是 TaskInfos 類別的索引子。