Share via


DataTypeInfoEnumerator.MoveNext Metode

Definisi

Memajukan enumerator ke elemen koleksi berikutnya.

public:
 virtual bool MoveNext();
public bool MoveNext ();
abstract member MoveNext : unit -> bool
override this.MoveNext : unit -> bool
Public Function MoveNext () As Boolean

Mengembalikan

Boolean yang menunjukkan apakah MoveNext() berhasil. true jika enumerator berhasil dimajukan ke elemen berikutnya; false jika enumerator telah melewati akhir koleksi

Penerapan

Contoh

Contoh kode berikut membuat enumerator, lalu menggunakan Currentmetode , MoveNext, dan Reset untuk menavigasi koleksi.

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.  
            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  
           ' of the collection.  
            ' 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  

Contoh Output:

Koleksi berisi nilai berikut:

[0] float DT_R4

[1] float presisi ganda DT_R8

[2] DT_CY mata uang

[3] tanggal DT_DATE

[4] Boolean DT_BOOL

[5] DT_DECIMAL desimal

[6] bilangan bulat bertanda tangan byte tunggal DT_I1

[7] bilangan bulat tunggal yang tidak ditandatangani DT_UI1

[8] bilangan bulat bertanda tangan dua byte DT_I2

[9] bilangan bulat dua byte yang tidak ditandatangani DT_UI2

[10] bilangan bulat bertanda empat byte DT_I4

[11] bilangan bulat empat byte yang tidak ditandatangani DT_UI4

[12] bilangan bulat bertanda tangan delapan byte DT_I8

[13] bilangan bulat delapan byte yang tidak ditandatangani DT_UI8

[14] tanda waktu file DT_FILETIME

[15] pengidentifikasi unik DT_GUID

[16] aliran byte DT_BYTES

[17] string DT_STR

[18] String Unicode DT_WSTR

[19] DT_NUMERIC numerik

[20] tanggal database DT_DBDATE

[21] waktu database DT_DBTIME

[22] tanda waktu database DT_DBTIMESTAMP

[23] gambar DT_IMAGE

[24] aliran teks DT_TEXT

[25] Aliran teks Unicode DT_NTEXT

Item pertama dalam enumerator setelah Reset:

float, DT_R4

Berlaku untuk