且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.NET / C# - 转换的char []字符串

更新时间:2023-02-17 08:20:20

 的char []字符= {'A​​','','S','T','R' ,'我','N','G'};
字符串s =新的字符串(字);
 

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.

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