Compartir a través de


ForEachEnumeratorInfosEnumerator.Current Propiedad

Returns the current ForEachEnumeratorInfo object from the collection.

Espacio de nombres:  Microsoft.SqlServer.Dts.Runtime
Ensamblado:  Microsoft.SqlServer.ManagedDTS (en Microsoft.SqlServer.ManagedDTS.dll)

Sintaxis

'Declaración
Public ReadOnly Property Current As ForEachEnumeratorInfo 
    Get
'Uso
Dim instance As ForEachEnumeratorInfosEnumerator 
Dim value As ForEachEnumeratorInfo 

value = instance.Current
public ForEachEnumeratorInfo Current { get; }
public:
property ForEachEnumeratorInfo^ Current {
    ForEachEnumeratorInfo^ get ();
}
member Current : ForEachEnumeratorInfo
function get Current () : ForEachEnumeratorInfo

Valor de la propiedad

Tipo: Microsoft.SqlServer.Dts.Runtime.ForEachEnumeratorInfo
The current ForEachEnumeratorInfo object in the collection.

Comentarios

After an enumerator is created, or after a call to the Reset method, the MoveNext method must be called to advance the enumerator to the first element of the collection before the enumerator can read the value of the Current property; otherwise, Current is undefined and throws an exception.

Current also throws an exception if the last call to MoveNext returned false, which indicates the end of the collection.

Current does not move the position of the enumerator, and consecutive calls to Current return the same object until either MoveNext or Reset is called.

An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is invalidated and becomes irrecoverable; thus, the next call to MoveNext or Reset throws an InvalidOperationException. However, if the collection is modified between calls to MoveNext and Current, Current returns the element that it is set to, even if the enumerator has been invalidated.

Ejemplos

The following code sample creates an enumerator, and then uses the Current and MoveNext methods to navigate over the collection.

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);
        }
    }
}

Sample Output:

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

Vea también

Referencia

ForEachEnumeratorInfosEnumerator Clase

Espacio de nombres Microsoft.SqlServer.Dts.Runtime