How to read characters from a string in C#?

Introduction:

In this article i will explain how to read characters from string in C#

Description:

In previous articles i explained How to replace string in C#, How to convert string to int in C#. In this article i will explain how to read characters from string in C#.

Example:

string Email = "vikram";

Now read all characters from Email.

// insert all characters into  Array.
var characters = Email.ToCharArray();

Now display each character from characters array in new line by using foreach.

foreach (char c in characters)
{
    // Display character by character.
    Console.WriteLine(" " + c + "\n");
}

Full Source Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpArticles
{
    class ReadCharacterByCharacter
    {
        public static void Main()
        {
            string Email = "vikram";
            // insert all characters into  Array.
            var characters = Email.ToCharArray();
            Console.WriteLine(" Characters: ");
            foreach (char c in characters)
            {
                // Display character by character.
                Console.WriteLine(" " + c + "\n");
            }
            Console.ReadLine();
        }
    }
}

Output: