Поделиться через


DataTypeInfos.Item[Object] Свойство

Определение

Возвращает объект 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

TypeName первой задачи: float

Комментарии

Если вызов метода Contains возвращается true, доступ к указанному элементу в коллекции можно получить с помощью синтаксиса DataTupeInfos[index]. Contains Если метод возвращаетсяfalse, это свойство создает исключение. В C# это свойство является индексатором класса DataTypeInfos.

Применяется к