DataTypeInfos.Item[Object] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從集合中回傳一個 DataTypeInfo 物件。
public:
property Microsoft::SqlServer::Dts::Runtime::DataTypeInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::DataTypeInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.DataTypeInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.DataTypeInfo
Default Public ReadOnly Property Item(index As Object) As DataTypeInfo
參數
- index
- Object
從集合中擷取物件的索引 DataTypeInfo 。
屬性值
DataTypeInfo 物件。
範例
以下程式碼範例使用兩種方法從集合中取得一個項目。 第一種方法是利用語 dataInfos[0] 法擷取集合中位於第一位置的整個物件並將其放入物件中 dtInfo 。 完成後,你可以像往常一樣從物件中取得所有屬性 dtInfo 。 第二種方法示範如何從集合中的第一個物件取得特定屬性。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace DataTypeInfos_GetEnum_Current
{
class Program
{
static void Main(string[] args)
{
//Create the DataTypeInfos collection.
DataTypeInfos dataInfos = new Application().DataTypeInfos;
//Using the Item method syntax of [x], obtain the first entry.
DataTypeInfo dtInfo = dataInfos[0];
String nameOfFirstItem = dataInfos[0].TypeName;
//Print the name of the task object located at position [0].
Console.WriteLine("The TypeEnumName of the first item is: {0}", dtInfo.TypeEnumName);
Console.WriteLine("The TypeName of the first task is: {0}", nameOfFirstItem);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace DataTypeInfos_GetEnum_Current
Class Program
Shared Sub Main(ByVal args() As String)
'Create the DataTypeInfos collection.
Dim dataInfos As DataTypeInfos = New Application().DataTypeInfos
'Using the Item method syntax of [x], obtain the first entry.
Dim dtInfo As DataTypeInfo = dataInfos(0)
Dim nameOfFirstItem As String = dataInfos(0).TypeName
'Print the name of the task object located at position [0].
Console.WriteLine("The TypeEnumName of the first item is: {0}", dtInfo.TypeEnumName)
Console.WriteLine("The TypeName of the first task is: {0}", nameOfFirstItem)
End Sub
End Class
End Namespace
範例輸出:
第一個項目的 TypeEnumName 為:DT_R4
第一個任務的類型名稱是:float
備註
如果呼叫 Contains 方法回傳 true,你可以透過語法 DataTupeInfos[index]存取集合中指定的元素。 若方法 Contains 回傳 false,此特性會拋出例外。 在 C# 中,這個屬性就是類別的 DataTypeInfos 索引器。