CharEnumerator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

what appears to be most appropriate iterating approach for CharEnumerator.


Do I have to call Reset in advance of any other method member?
 
If you are iterating over the same string only once, You might NOT need
to call Reset
eg

public class MyClass
{
public static void Main()
{
CharEnumerator ch;
string s = "this is a very very long string";
ch = s.GetEnumerator();

while (ch.MoveNext())
{
Console.Write(ch.Current);
}
//ch.Reset();

while (ch.MoveNext())
{
Console.Write(ch.Current);
}
}
}

See the difference by uncommenting ch.Reset()

HTH
Kalpesh
 
Back
Top