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

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

问题描述

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

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

来自字符数组的 ToString() 方法不起作用.

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天全站免登陆