Udostępnij za pośrednictwem


IEnumerator<T>.Current Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the element in the collection at the current position of the enumerator.

Namespace:  System.Collections.Generic
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
ReadOnly Property Current As T
T Current { get; }

Property Value

Type: T
The element in the collection at the current position of the enumerator.

Remarks

Current is undefined under any of the following conditions:

  • The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. MoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Current.

  • The last call to MoveNext returned false, which indicates the end of the collection.

  • The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.

Current returns the same object until MoveNext is called. MoveNext sets Current to the next element.

Notes to Implementers

Implementing this interface requires implementing the nongeneric IEnumerator interface. The Current property appears on both interfaces, and has different return types. Implement the nongeneric IEnumerator.Current property as an explicit interface implementation. This allows any consumer of the nongeneric interface to consume the generic interface.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.