[Serializable] |
Text element enumerators are intended to be used only to read data in the string. Enumerators cannot be used to modify the underlying string.
The enumerator does not have exclusive access to the string.
When an enumerator is created, it takes a snapshot of the current state of the string. If changes are made to the string, such as adding, modifying, or deleting text elements, the snapshot gets out of sync and the enumerator throws an InvalidOperationException. Two enumerators created from the same string at the same time can have different snapshots of the string.
The enumerator is in an invalid state if it is positioned before the first text element in the string or after the last text element in the string. Whenever the enumerator is in an invalid state, calling TextElementEnumerator.Current throws an exception.
Initially, the enumerator is positioned before the first text element in the string. TextElementEnumerator.Reset also brings the enumerator back to this position. Therefore, after an enumerator is created or after a TextElementEnumerator.Reset, TextElementEnumerator.MoveNext must be called to advance the enumerator to the first text element of the string before reading the value of TextElementEnumerator.Current.
TextElementEnumerator.Current returns the same object until either TextElementEnumerator.MoveNext or TextElementEnumerator.Reset is called.
After the end of the string is passed, the enumerator is again in an invalid state and calling TextElementEnumerator.MoveNext returns false. Calling TextElementEnumerator.Current throws an exception if the last call to TextElementEnumerator.MoveNext returned false.
Current | Read-only Gets the current text element in the string. |
ElementIndex | Read-only Gets the index of the text element that the enumerator is currently positioned over. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetTextElement | Gets the current text element in the string. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
MoveNext | Advances the enumerator to the next text element of the string. |
Reset | Sets the enumerator to its initial position, which is before the first text element in the string. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public object Current {get;}
|
Exception Type | Condition |
---|---|
InvalidOperationException | The enumerator is positioned before the first text element of the string or after the last text element. |
After an enumerator is created or after a TextElementEnumerator.Reset, TextElementEnumerator.MoveNext must be called to advance the enumerator to the first text element of the string before reading the value of TextElementEnumerator.Current; otherwise, TextElementEnumerator.Current is undefined.
TextElementEnumerator.Current also throws an exception if the last call to TextElementEnumerator.MoveNext returned false, which indicates the end of the string.
TextElementEnumerator.Current does not move the position of the enumerator and consecutive calls to TextElementEnumerator.Current return the same object until either TextElementEnumerator.MoveNext or TextElementEnumerator.Reset is called.
public int ElementIndex {get;}
|
Exception Type | Condition |
---|---|
InvalidOperationException | The enumerator is positioned before the first text element of the string or after the last text element. |
~TextElementEnumerator(); |
public virtual int GetHashCode(); |
public string GetTextElement(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The enumerator is positioned before the first text element of the string or after the last text element. |
This method returns the same text element as the TextElementEnumerator.Current property.
public Type GetType(); |
protected object MemberwiseClone(); |
public bool MoveNext(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The string was modified after the enumerator was created. |
After an enumerator is created or after a call to TextElementEnumerator.Reset, the enumerator is positioned before the first text element of the string, and the first call to TextElementEnumerator.MoveNext moves the enumerator over the first text element of the string.
If the string is modified after this enumerator was created, TextElementEnumerator.MoveNext throws an exception.
After the end of the string is passed, subsequent calls to TextElementEnumerator.MoveNext return false until TextElementEnumerator.Reset is called.
public void Reset(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The string was modified after the enumerator was created. |
TextElementEnumerator.Reset moves the enumerator to the beginning of the string, before the first text element. After TextElementEnumerator.Reset, TextElementEnumerator.MoveNext must be called to advance the enumerator to the first text element of the string before reading the value of TextElementEnumerator.Current.
public virtual string ToString(); |