言語

DataTypeInfoEnumerator.Current プロパティ

定義

コレクション内の現在の要素を取得します。

public:
 property System::Object ^ Current { System::Object ^ get(); };
public object Current { get; }
member this.Current : obj
Public ReadOnly Property Current As Object

プロパティ値

コレクション内の現在の要素。

実装

以下のコードサンプルは列挙子を作成し、 CurrentMoveNextReset の各メソッドを使ってコレクションをナビゲートします。

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] 浮かべDT_R4

[1] 二重精度フロートDT_R8

[2] 通貨DT_CY

[3] 日付DT_DATE

[4] ブールDT_BOOL

[5] 小数DT_DECIMAL

[6] シングルバイト符号付き整数DT_I1

[7] 単バイトの符号なし整数DT_UI1

[8] 2バイト署名整数DT_I2

[9] 2バイトの符号なし整数DT_UI2

[10] 4バイト署名整数DT_I4

[11] 4バイトの符号なし整数DT_UI4

[12] 8バイト署名整数DT_I8

[13] 8バイトの符号なし整数DT_UI8

[14] ファイルのタイムスタンプ DT_FILETIME

[15] 一意識別子DT_GUID

[16] バイトストリームDT_BYTES

[17] 弦DT_STR

[18] Unicode文字列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

注釈

列挙子が作成された後、または Reset メソッドへの呼び出し後、 MoveNext メソッドを呼び出して列挙子をコレクションの最初の要素に進めなければ Current プロパティの値を読み取れません。そうでなければ、 Current は未定義で例外を投げます。

Current また、 MoveNext の最後の呼び出しが false返された場合も例外がスローされます。これはコレクションの末尾を示します。

Current 列挙子の位置は移動せず、 Current への連続呼び出しは MoveNext または Reset のいずれかが呼び出すまで同じオブジェクトを返します。

列挙子は、コレクションが変更されない限り有効なままです。 要素の追加、修正、削除などの変更が加えられると、列挙子は無効化され、回復不能になります。 MoveNextCurrentの呼び出し間でコレクションが変更された場合、Currentは設定された要素を返します。列挙子が無効化されていてもです。

適用対象