C# – .NET / C# – Convert char[] to string

arraysccharnetstring

What is the proper way to turn a char[] into a string?

The ToString() method from an array of characters doesn't do the trick.

Best Answer

There's a constructor for this:

char[] chars = {'a', ' ', 's', 't', 'r', 'i', 'n', 'g'};
string s = new string(chars);