In this C#.Net tutorial, I will explain, how to convert char array to a string in C#.Net.
To convert a char array to a string in C#.Net, use one of the following 5 methods:
- Using the string Constructor
- Using string.Join()
- Using StringBuilder
- Using string.Concat()
- Using LINQ’s Aggregate Method
Convert Char Array to String in C#.NET
Let us check the 5 different methods to convert a char array to a string in C#.Net.
Using the string
Constructor
The string
class in C# has a constructor that takes a char array as an argument and returns a new string that represents the characters in the array.
Example:
using System;
namespace CharArrayToStringExample
{
class Program
{
static void Main(string[] args)
{
char[] charArray = {'H', 'e', 'l', 'l', 'o'};
string str = new string(charArray);
Console.WriteLine(str); // Output: Hello
}
}
}
Once you run the code using Visual Studio, you can see the output below:

Using string.Join()
The string.Join()
method can be used to join elements of an array into a string in C#. Even though this method is generally used to join strings, it can also work on char arrays if you specify an empty separator.
Example:
using System;
namespace CharArrayToStringExample
{
class Program
{
static void Main(string[] args)
{
char[] charArray = {'W', 'o', 'r', 'l', 'd'};
string str = string.Join("", charArray);
Console.WriteLine(str); // Output: World
}
}
}
You can see the output like below:

Using StringBuilder
StringBuilder
is a mutable sequence of characters, and it’s a part of the System.Text namespace. It can be used to convert a char array to a string by appending each character to the StringBuilder object and then converting it to a string.
Example:
using System;
using System.Text;
namespace CharArrayToStringExample
{
class Program
{
static void Main(string[] args)
{
char[] charArray = {'!', ' ', 'H', 'i'};
StringBuilder sb = new StringBuilder();
foreach (char ch in charArray)
{
sb.Append(ch);
}
string str = sb.ToString();
Console.WriteLine(str); // Output: ! Hi
}
}
}
Using string.Concat()
The string.Concat()
method concatenates the string representations of two or more objects. It can also be used to convert a char array to a string.
Example:
using System;
namespace CharArrayToStringExample
{
class Program
{
static void Main(string[] args)
{
char[] charArray = {'C', '#', '.', 'N', 'E', 'T'};
string str = string.Concat(charArray);
Console.WriteLine(str); // Output: C#.NET
}
}
}
Using LINQ’s Aggregate
Method
LINQ offers an Aggregate
method that can be used to convert a char array to a string as well. Here’s how to do it:
Example:
using System;
using System.Linq;
namespace CharArrayToStringExample
{
class Program
{
static void Main(string[] args)
{
char[] charArray = {'E', 'x', 'a', 'm', 'p', 'l', 'e'};
string str = charArray.Aggregate("", (current, next) => current + next);
Console.WriteLine(str); // Output: Example
}
}
}
Performance Considerations
When choosing a method for conversion, it’s essential to consider the performance implications:
- Using the
string
constructor is generally the most efficient way to convert a char array to a string. StringBuilder
is more efficient for large arrays or when you need to perform multiple string manipulations.string.Join()
andstring.Concat()
are convenient but may not be as efficient for large arrays.- Using LINQ’s
Aggregate
method is the least efficient of all these methods.
Conclusion
In this C#.Net tutorial, I have shown you with practical example of how to convert a char array to a string in C#.NET using various methods.
You may also like:
- Reverse an Array in C# Without Using Reverse Function
- How to reverse a string in C# using Linq?
- How to reverse a string in C# using inbuilt function?
- Remove Duplicates in a C# Array
Bijay Kumar is a renowned software engineer, accomplished author, and distinguished Microsoft Most Valuable Professional (MVP) specializing in SharePoint. With a rich professional background spanning over 15 years, Bijay has established himself as an authority in the field of information technology. He possesses unparalleled expertise in multiple programming languages and technologies such as ASP.NET, ASP.NET MVC, C#.NET, and SharePoint, which has enabled him to develop innovative and cutting-edge solutions for clients across the globe. Read more…