DBProviderInfoEnumerator.Current プロパティ

定義

現在の DBProviderInfo オブジェクトをコレクションから返します。

public:
 property Microsoft::SqlServer::Dts::Runtime::DBProviderInfo ^ Current { Microsoft::SqlServer::Dts::Runtime::DBProviderInfo ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.DBProviderInfo Current { get; }
member this.Current : Microsoft.SqlServer.Dts.Runtime.DBProviderInfo
Public ReadOnly Property Current As DBProviderInfo

プロパティ値

現在の DBProviderInfo オブジェクト。

次のコード サンプルでは、列挙子を作成してから、Current メソッドおよび MoveNext メソッドを使用してコレクションを移動します。

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace DBProvInfos_GetEnum  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application app = new Application();  
            DBProviderInfos dbprovInfos = app.DBProviderInfos;  

            //Create the Enumerator.  
            DBProviderInfoEnumerator myEnumerator = dbprovInfos.GetEnumerator();  
            Console.WriteLine("The collection contains the following values:");  
            int i = 0;  
            while ((myEnuemrator.MoveNext()) && (myEnuemrator.Current != null))  
                Console.WriteLine("[{0}] {1}", i++, myEnuemrator.Current.Name);  

        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace DBProvInfos_GetEnum  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   
            Dim dbprovInfos As DBProviderInfos =  app.DBProviderInfos   

            'Create the Enumerator.  
            Dim myEnumerator As DBProviderInfoEnumerator =  dbprovInfos.GetEnumerator()   
            Console.WriteLine("The collection contains the following values:")  
            Dim i As Integer =  0   
            While (myEnuemrator.MoveNext()) &&(myEnuemrator.Current <> Nothing)  
            Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1  
            End While  

        End Sub  
    End Class  
End Namespace  

サンプル出力:

The collection contains the following values:

注釈

列挙子を作成した後や Reset メソッドを呼び出した後は、MoveNext プロパティの値を読み取る前に、Current メソッドを呼び出して列挙子をコレクションの先頭の要素に進めておく必要があります。そうしないと、Current は未定義となり、例外がスローされます。

前回の MoveNext の呼び出しで false が返された場合 (コレクションの末尾であることを示します)、その後で Current を呼び出しても例外がスローされます。

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

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

適用対象