We have given a character array arr and the task is to convert char array to string str in C#.
Input: arr = [s, t, r, i, n, g] Output: string Input: arr = [G, e, e, k, s, F, o, r, G, e, e, k, s] Output: GeeksForGeeks
In order to do this task, we have the following methods:
Method 1:
Using string() Method: The String class has several overloaded constructors which take an array of characters or bytes. Thus it can be used to create a new string from the character array.
Syntax:
string str = new string(character_array);
Example:
C#
// C# program to convert the // char array to string using System; using System.Text; public class GFG{ static string getString(char[] arr) { // string() is a used to // convert the char array // to string string s = new string(arr); return s; } static void Main(string[] args) { // given character array char[] arr = {'G', 'e', 'e', 'k', 's', 'F', 'o', 'r', 'G', 'e', 'e', 'k', 's'}; // function calling string str = getString(arr); // printing output Console.WriteLine(str); } } |
Output:
GeeksForGeeks
Method 2:
Using Join() Method: This method is used to concatenates the members of a collection or the elements of the specified array, using the specified separator between each member or element. Thus it can be used to create a new string from the character array.
Syntax:
string str = string.Join("", character_array);
Example:
C#
// C# program to convert the // char array to string using System; using System.Text; public class GFG{ static string getString(char[] arr) { // String.Join() is a used to // convert the char array // to string string s = string.Join("", arr); return s; } static void Main(string[] args) { // given character array char[] arr = {'G', 'e', 'e', 'k', 's', 'F', 'o', 'r', 'G', 'e', 'e', 'k', 's'}; // function calling string str = getString(arr); // printing output Console.WriteLine(str); } } |
Output:
GeeksForGeeks
Method 3:
Using Concat() Method: This method is used to concatenate one or more instances of String or the String representations of the values of one or more instances of Object. Thus it can be used to create a new string from the character array.
Syntax:
string str = string.Concat(character_array);
Example:
C#
// C# program to convert the // char array to string using System; using System.Text; public class GFG{ static string getString(char[] arr) { // String.Concat() is a used to // convert the char array // to string string s = string.Concat(arr); return s; } static void Main(string[] args) { // given character array char[] arr = {'G', 'e', 'e', 'k', 's', 'F', 'o', 'r', 'G', 'e', 'e', 'k', 's'}; // function calling string str = getString(arr); // printing output Console.WriteLine(str); } } |
Output:
GeeksForGeeks
Recommended Posts:
- Different ways to convert String to Integer in C#
- Convert String to Character Array in C#
- How to Convert ASCII Char to Byte in C#?
- Different Ways to Convert Double to Integer in C#
- C# | Char.Parse(String) Method
- C# | Char.ConvertToUtf32(String, Int32) Method
- C# | Char.IsHighSurrogate(String, Int32) Method
- C# | Char.IsSurrogatePair(String, Int32) Method
- C# | Char.IsSurrogate(String, Int32) Method
- C# | Char.IsControl(String, Int32) Method
- C# | Char.IsLowSurrogate(String, Int32) Method
- C# | Char.GetUnicodeCategory(String, Int32) Method with Examples
- C# | Char.ToUpperInvariant(Char) Method
- C# | Char.ToLowerInvariant(Char) Method
- Convert a Character to the String in C#
- C# | Convert.FromBase64String(String) Method
- C# | Convert.ToUInt16(String, IFormatProvider) Method
- C# | Convert.ToUInt32(String, IFormatProvider) Method
- C# | Convert.ToInt64(String, IFormatProvider) Method
- C# | Convert.ToInt32(String, IFormatProvider) Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

