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] Поток текста Unicode DT_NTEXT
Первый элемент в переписчике после сброса:
Парить, DT_R4