Get all characters of a String in C#

In this article we will discuss about how to get all the characters of the string in C#.
  • 3607

A string is a collection of characters.

The following code snippet reads all characters of a string and displays on the console.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string nameString = "Mahesh Chand";
            for (int counter = 0; counter <= nameString.Length - 1;counter++)
            {
                Console.WriteLine(nameString[counter]);
            }
            Console.ReadLine();
        }
    }
}


Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.