DataTypeInfoEnumerator.MoveNext Method ()


Advances the enumerator to the next element of the collection.

Namespace:   Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public bool MoveNext()

Return Value

Type: System.Boolean

A Boolean that indicates if MoveNext was successful. true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection

The following code example creates an enumerator, and then uses the Current, MoveNext, and Reset methods to navigate over the collection.

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
           // of the collection.
            // Do not retrieve from the collection until MoveNext is called.

            // 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);

Sample Output:

The collection contains the following values:

[0] float DT_R4

[1] double-precision float DT_R8

[2] currency DT_CY

[3] date DT_DATE

[4] Boolean DT_BOOL

[5] decimal DT_DECIMAL

[6] single-byte signed integer DT_I1

[7] single-byte unsigned integer DT_UI1

[8] two-byte signed integer DT_I2

[9] two-byte unsigned integer DT_UI2

[10] four-byte signed integer DT_I4

[11] four-byte unsigned integer DT_UI4

[12] eight-byte signed integer DT_I8

[13] eight-byte unsigned integer DT_UI8

[14] file timestamp DT_FILETIME

[15] unique identifier DT_GUID

[16] byte stream DT_BYTES

[17] string DT_STR

[18] Unicode string DT_WSTR

[19] numeric DT_NUMERIC

[20] database date DT_DBDATE

[21] database time DT_DBTIME

[22] database timestamp DT_DBTIMESTAMP

[23] image DT_IMAGE

[24] text stream DT_TEXT

[25] Unicode text stream DT_NTEXT

The first item in the enumerator after Reset:

float, DT_R4

Return to top