This documentation is archived and is not being maintained.

CharEnumerator.Current Property

Gets the character in the enumerated string currently indexed by this instance.

[Visual Basic]
Public ReadOnly Property Current As Char
public char Current {get;}
public: __property __wchar_t get_Current();
public function get Current() : Char;

Property Value

The Unicode character referenced by the index, if the index is valid.


Exception Type Condition
InvalidOperationException The index is invalid; that is, it is before the first or after the last character of the enumerated string.


This property should only be invoked when the index maintained by this instance is valid, otherwise, an exception is thrown. The index is always invalid for an empty string ("").

The index is invalid after the String.GetEnumerator or Reset method is called. After either of these methods is called, invoke the MoveNext method to adjust the index to the first character in the enumerated string. The index is valid whenever the MoveNext method returns true.

Current does not move the index, and consecutive calls to Current return the same character until MoveNext, Reset, or String.GetEnumerator is called.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

CharEnumerator Class | CharEnumerator Members | System Namespace