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  a  v  a2s.  c  o  m
        string welcome = "Welcome, to C# Basics.";
        foreach (char c in welcome)
        {
            Console.Write(c);
        }
    }
}

Result