Freigeben über


DataTypeInfoEnumerator.Reset Methode

Definition

Setzt den Enumerator auf seine anfängliche Position vor dem ersten Element in der Auflistung.

public:
 virtual void Reset();
public void Reset ();
abstract member Reset : unit -> unit
override this.Reset : unit -> unit
Public Sub Reset ()

Implementiert

Beispiele

Im folgenden Codebeispiel wird ein Aufzählungszeichen erstellt, und dann wird die CurrentMoveNextReset Methoden verwendet, um über die Auflistung zu navigieren.

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  

Beispielausgabe:

Die Auflistung enthält die folgenden Werte:

[0] Float DT_R4

[1] Double-Precision Float DT_R8

[2] Währung DT_CY

[3] Datum DT_DATE

[4] Boolesche DT_BOOL

[5] Dezimal-DT_DECIMAL

[6] Ein-Byte-ganzzahlige DT_I1

[7] Single-Byte unsignierte ganze Zahl DT_UI1

[8] Zwei byte signierte ganzzahlige DT_I2

[9] Zwei-Byte nicht signierte ganzzahlige DT_UI2

[10] Vier byte signierte ganze Zahl DT_I4

[11] Vier byte nicht signierte ganze Zahl DT_UI4

[12] Acht byte signierte ganze Zahl DT_I8

[13] Acht byte nicht signierte ganzzahlige DT_UI8

[14] Dateizeitstempel DT_FILETIME

[15] eindeutiger Bezeichner DT_GUID

[16] Bytestrom DT_BYTES

[17] Zeichenfolge DT_STR

[18] Unicode-Zeichenfolge DT_WSTR

[19] numerische DT_NUMERIC

[20] Datenbankdatum DT_DBDATE

[21] Datenbankzeit DT_DBTIME

[22] Datenbankzeitstempel DT_DBTIMESTAMP

[23] Bild DT_IMAGE

[24] Textstrom DT_TEXT

[25] Unicode-Textstrom DT_NTEXT

Das erste Element im Aufzählerator nach dem Zurücksetzen:

Float, DT_R4

Gilt für: