find and solve || findandsolve.com
Please wait.....

C# String GetEnumerator()

The C# GetEnumerator() method is used to convert string object into char enumerator. It returns instance of CharEnumerator.It returns an enumerator that iterates through the List<T>

Method

public CharEnumerator GetEnumerator()  

Parameter

It does not take any argument.

Return

It returns System.CharEnumerator.

C# String GetEnumerator() Method Example

using System;
public class StringExample
{
    public static void Main(string[] args)
    {
      string str= "Hello Word#";
      CharEnumerator cha = str.GetEnumerator();
      while(cha.MoveNext()){
      Console.WriteLine(cha.Current);
      }
    }
}    
Output
H
e
l
l
o
W
o
r
d
#