String Getenumerator() - C# Tutorial
C# Course / Strings / String Getenumerator()

String Getenumerator()

BLUF: Mastering String Getenumerator() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Getenumerator()

C# is a powerful, modern language for enterprise solutions. Discover how String Getenumerator() enhances your development workflow in the guide below.

The C# GetEnumerator function is employed to transform a string object into a character enumerator, which yields an instance of CharEnumerator. This enables the iteration of a string using a loop.

Signature

Example

public CharEnumerator GetEnumerator()

Parameter

It does not take any argument.

Return

It returns System.CharEnumerator.

C# String GetEnumerator Method Example

Example

using System;  
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
          string s2 = "Hello C#";
          CharEnumerator ch = s2.GetEnumerator();
          while(ch.MoveNext()){
            Console.WriteLine(ch.Current);
          }
        }  
    }

Output:

Output

H
e
l
l
o
 
C
#

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience