ForEachEnumeratorInfosEnumerator.Current プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の ForEachEnumeratorInfo オブジェクトをコレクションから返します。
public:
property Microsoft::SqlServer::Dts::Runtime::ForEachEnumeratorInfo ^ Current { Microsoft::SqlServer::Dts::Runtime::ForEachEnumeratorInfo ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorInfo Current { get; }
member this.Current : Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorInfo
Public ReadOnly Property Current As ForEachEnumeratorInfo
プロパティ値
コレクション内にある現在の ForEachEnumeratorInfo オブジェクトです。
例
次のコード サンプルでは、列挙子を作成してから、Current メソッドと MoveNext メソッドを使用してコレクションを移動します。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Enumerators.Item;
namespace ForEachEnums
{
class Program
{
static void Main(string[] args)
{
Application app = new Application();
ForEachEnumeratorInfos feInfos = app.ForEachEnumeratorInfos;
//Create the Enumerator.
ForEachEnumeratorInfosEnumerator myEnumerator = feInfos.GetEnumerator();
Console.WriteLine("The collection contains the following values:");
int i = 0;
while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Name);
}
}
}
サンプル出力:
The collection contains the following values:
[0] For Each File Enumerator
[1] For Each Item Enumerator
[2] For Each ADO Enumerator
[3] For Each ADO.NET Schema Rowset Enumerator
[4] For Each From Variable Enumerator
[5] For Each NodeList Enumerator
[6] For Each SMO Enumerator
注釈
列挙子が作成された後、または Reset メソッドの呼び出し後に、 MoveNext メソッドを呼び出して、列挙子が Current プロパティの値を読み取る前に、列挙子をコレクションの最初の要素に進める必要があります。それ以外の場合、 Current は未定義であり、例外をスローします。
コレクション の末尾を示す MoveNext の最後の呼び出しが返された false
場合も、Current は例外をスローします。
Current は列挙子の位置を移動せず、 Current を連続して呼び出すと 、MoveNext または Reset が呼び出されるまで同じオブジェクトが返されます。
列挙子は、コレクションが変更されない限り有効です。 要素の追加、変更、削除など、コレクションに変更が加えられた場合、列挙子は無効になり、回復不能になります。したがって、 MoveNext または Reset の次の呼び出しは InvalidOperationException をスローします。 ただし、 MoveNext と Current の呼び出しの間でコレクションが変更された場合、列挙子が無効になっている場合でも、 Current は設定されている要素を返します。