C# Char Array To String

C# Char Array To String

Is there any way to convert character array to string using C#.net? Yes. Just create new instance of the string and pass array of characters to constructor of it.

C# Character array to string conversion example

using System;

namespace CharArray.ToStringConversion.Example
{
    class Program
    {
        static void Main(string[] args)
        {

          char[] arrChar = new char[11] { 'a','b','c','d','S','A','T','A','L','A','J' } ;
          
          string str = new string(arrChar);

          Console.WriteLine(arrChar);
                  
          Console.ReadLine();
              
        } 
    } 
}

Output

abcdSATALAJ

Short example

 char[] arrChar = new char[5] { 'a','b','c','d','e'} ;          
string str = new string(arrChar);

Note String is noting but representation of Unicode character element in sequence.

C# DateTime ToString()How To Declare and access array of string in C#C# Char Array[C#] Remove Last Character From Stringc# arraylistC# Char Array To StringC# foreach loopConvert Array To Comma Separated String C#c# string first character uppercaseSplit String In C#Replace string in C#

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.