.NET / C# - 转换的char []字符串 [英] .NET / C# - Convert char[] to string

查看:184
本文介绍了.NET / C# - 转换的char []字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是正确的方法可以把的char [] 成字符串?

这是一个字符数组的的ToString()方法不会做的伎俩。

解决方案

 的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);

这篇关于.NET / C# - 转换的char []字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆