Convert string to character array in C#

In this article we will discuss about how to convert a string to character array in C#.
  • 3813

To convert a string into character array we need to use  ToCharArray() method. 

Here is example
 to show the following:

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

namespace ConsoleApplication5
    class Program
        static void Main(string[] args)
            string value = "Dot Net Heaven";
            // Use ToCharArray to convert string to array.
            char[] array = value.ToCharArray();
            // Loop through array.
            for (int i = 0; i < array.Length; i++)
                // Get character from array.
                char letter = array[i];
                // Display each letter.
                Console.Write("Letter: ");


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


More Articles

© 2020 DotNetHeaven. All rights reserved.