char[] chars = {'a', ' ', 's', 't', 'r', 'i', 'n', 'g'};
string s = new string(chars);
93
votes
Use the constructor of string which accepts a char[]
char[] c = ...;
string s = new string(c);
39
votes
char[] characters;
...
string s = new string(characters);
30
votes
One other way:
char[] chars = {'a', ' ', 's', 't', 'r', 'i', 'n', 'g'};
string s = string.Join("", chars);
//we get "a string"
// or for fun:
string s = string.Join("_", chars);
//we get "a_ _s_t_r_i_n_g"
22
votes
String mystring = new String(mychararray);
18
votes
Use the string constructor which accepts chararray as argument, start position and length of array. Syntax is given below:
string charToString = new string(CharArray, 0, CharArray.Count());
16
votes
Another alternative
char[] c = { 'R', 'o', 'c', 'k', '-', '&', '-', 'R', 'o', 'l', 'l' };
string s = String.Concat( c );
Debug.Assert( s.Equals( "Rock-&-Roll" ) );
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more