我们首先设置一个5个字符的数组-
char[] ch = new char[15]; ch[0] = 'T'; ch[1] = 'r'; ch[2] = 'i'; ch[3] = 'c'; ch[4] = 'k';
现在将它们转换为字符串-
string str = new string(ch);
这是完整的代码-
Using System; class Program { static void Main() { char[] ch = new char[15]; ch[0] = 'T'; ch[1] = 'r'; ch[2] = 'i'; ch[3] = 'c'; ch[4] = 'k'; //转换为字符串 string str = new string(ch); Console.WriteLine(str); } }