Published on: 01 Apr, 2021

How to convert char array to string in C#?

Tumblr Digg Google Plus

If you need to convert a char array to string in C#. You can use declare a new string and pass the char array in the string constructor.

See below code in C#.

char[] letterChars = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
string letterString = new string(letterChars);

This is the example we run above code in C# windows console app.

using System;
using System.Collections.Generic;
namespace ConsoleApp
{
    class Program
    {
        public static void Main(string[] args)
        {
            char[] letterChars = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' };
            string letterString = new string(letterChars);
            Console.WriteLine(string.Format("Result: {0}", letterString));
            Console.Read();
        }
    }
}

Sample Result.

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.