言語

TaskInfos.Item[Object] プロパティ

定義

コレクションから 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

パラメーター

index
Object

コレクションから取得する TaskInfo の名前、ID、またはインデックスです。

プロパティ値

TaskInfo オブジェクトです。

以下のコード例は、コレクションからアイテムを取得するために2つの方法を用います。 最初の方法は tInfos[0] 構文を用いて、コレクションの最初の位置にあるオブジェクト全体を取得し、 tInfo オブジェクトに配置します。 通常通り tInfo オブジェクトからすべてのプロパティを取得することができます。 2つ目の方法は、コレクションの最初のオブジェクトから特定のプロパティを取得する方法を示しています。

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}です。

最初のタスクの名前は「Execute Package Task」です

注釈

Containsメソッドの呼び出しがtrue返された場合、構文TaskInfos[index]を使ってコレクション内の指定された要素にアクセスできます。 しかし、メソッドへの呼び出しがfalseContains場合、この性質は例外を投げ出します。 C# では、このプロパティは TaskInfos クラスのインデクサーです。

適用対象