asp.net.ph

CharEnumerator Class

System Namespace


Supports iterating over, and providing read-only access to, the individual characters in a String.

CharEnumerator Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Current Char [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public Clone ( ) Object
public Dispose ( ) Void
public MoveNext ( ) Boolean
public Reset ( ) Void

Remarks

An instance of CharEnumerator is used to support the foreach statement of the Microsoft Visual Basic and C# programming languages, and provide read-only access to the characters in a String object.

When a CharEnumerator is instantiated, it saves the current "view" of the String. Several independent instances of CharEnumerator, each with its own view, can exist simultaneously for a single instance of String. Modifications to the underlying String invalidate the associated view, causing all subsequent CharEnumerator method operations to throw an exception.

An instance of CharEnumerator maintains information specifying its current character position in a String. The state of that position is valid when it is over a character within the String, and invalid when it is before the first character or after the last character in the String. Attempting any method operation while the character position is in an invalid state throws and exception.

Initially, the current character position is before the first character in the String. That position can be incremented by one with the MoveNext method, and returned to before the first character with the Reset method. The character at the current character position can be retrieved with the Current property.

See Also

String   IEnumerator   IEnumerable   ICollection Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph