CSharp - Write program to traverse character by character in a String

Requirements

Write program to traverse character by character in a String

Hint

Strings implement IEnumerable<char>. We can use the foreach loop in such a context:

Demo

using System;

public class MainClass
{
    public static void Main(String[] argv)
    {/* w  w  w. j  av  a2 s. c  om*/
        string welcome = "Welcome, to C# Basics.";
        foreach (char c in welcome)
        {
            Console.Write(c);
        }
    }
}

Result