C# allows users to convert a character array (e.g., char[] arr
) to a String
.
We can perform this conversion by passing the character array to a string constructor.
Consider the following syntax:
string str = new string (char_arr)
In the code below, we have a character array arr
that contains h
e
l
l
o
. By using a built-in string constructor, we can convert this character array into a string.
class HelloWorld{static void Main(){char[] arr={'H','e','l','l','o'};string str = new string (arr);System.Console.WriteLine(str);}}