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


DataTypeInfos.GetEnumerator Метод

Определение

Возвращает перечислитель DataTypeInfoEnumerator, служащий для прохода по коллекции DataTypeInfo.

public:
 Microsoft::SqlServer::Dts::Runtime::DataTypeInfoEnumerator ^ GetEnumerator();
public Microsoft.SqlServer.Dts.Runtime.DataTypeInfoEnumerator GetEnumerator ();
override this.GetEnumerator : unit -> Microsoft.SqlServer.Dts.Runtime.DataTypeInfoEnumerator
Public Function GetEnumerator () As DataTypeInfoEnumerator

Возвращаемое значение

Объект DataTypeInfoEnumerator для коллекции DataTypeInfo.

Примеры

В следующем примере кода создается DataTypeInfoEnumerator метод, GetEnumerator а затем выполняется итерацию по коллекции.

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;  

            //Create the enumerator.  
            DataTypeInfoEnumerator myEnumerator = dataInfos.GetEnumerator();  
            Console.WriteLine("The collection contains the following values:");  
            int i = 0;  
            DataTypeInfo dtiObject;  
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))  
            {  
                dtiObject = (DataTypeInfo)myEnumerator.Current;  
                Console.WriteLine("[{0}] {1} {2}", i++, dtiObject.TypeName, dtiObject.TypeEnumName);  
            }  
            // Reset puts the index pointer before the beginning.  
            // Do not retrieve from the collection until MoveNext is called.  
            myEnumerator.Reset();  
            myEnumerator.MoveNext();  
            // Now that the enumerator has been reset, and moved to the  
            // first item in the collection, show the first item.  
            dtiObject = (DataTypeInfo)myEnumerator.Current;  
            Console.WriteLine("The first item in the enumerator after Reset:");  
            Console.WriteLine("{0}, {1}", dtiObject.TypeName, dtiObject.TypeEnumName);  
        }  
    }  
}  
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   

            'Create the Enumerator.  
            Dim myEnumerator As DataTypeInfoEnumerator =  dataInfos.GetEnumerator()   
            Console.WriteLine("The collection contains the following values:")  
            Dim i As Integer =  0   
            Dim dtiObject As DataTypeInfo  
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)  
                dtiObject = CType(myEnumerator.Current, DataTypeInfo)  
                Console.WriteLine("[{0}] {1} {2}",i = Console.WriteLine("[{0}] {1} {2}",i + 1  
            End While  
            ' Reset puts the index pointer before the beginning.  
            ' Do not retrieve from the collection until MoveNext is called.  
            myEnumerator.Reset()  
            myEnumerator.MoveNext()  
            ' Now that the enumerator has been reset, and moved to the  
            ' first item in the collection, show the first item.  
            dtiObject = CType(myEnumerator.Current, DataTypeInfo)  
            Console.WriteLine("The first item in the enumerator after Reset:")  
            Console.WriteLine("{0}, {1}", dtiObject.TypeName, dtiObject.TypeEnumName)  
        End Sub  
    End Class  
End Namespace  

Образец вывода:

Коллекция содержит следующие значения:

[0] float DT_R4

[1] DT_R8 с плавающей запятой двойной точности

[2] DT_CY валюты

[3] дата DT_DATE

[4] Логический DT_BOOL

[5] десятичные DT_DECIMAL

[6] Однобайтовое целое число со знаком DT_I1

[7] Однобайтовое целое число без знака DT_UI1

[8] Двухбайтовое целое число со знаком DT_I2

[9] Двухбайтовое целое число без знака DT_UI2

[10] Четырехбайтовое целое число со знаком DT_I4

[11] Четырехбайтовое целое число без знака DT_UI4

[12] Восьмибайтовое целое число со знаком DT_I8

[13] Восьмибайтовое целое число без знака DT_UI8

[14] метка времени файла DT_FILETIME

[15] Уникальный идентификатор DT_GUID

[16] Поток байтов DT_BYTES

[17] строка DT_STR

[18] Строка Юникода DT_WSTR

[19] Числовые DT_NUMERIC

[20] Дата базы данных DT_DBDATE

[21] время базы данных DT_DBTIME

[22] DT_DBTIMESTAMP метки времени базы данных

[23] изображение DT_IMAGE

[24] Текстовый поток DT_TEXT

[25] Текстовый поток Юникода DT_NTEXT

Первый элемент в перечислителе после сброса:

float, DT_R4

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