您好,欢迎访问一九零五行业门户网

C#程序将字符列表转换为字符串

首先,声明字符数组并设置每个字符的值 −
char[] ch = new char[5];ch[0] = 'h';ch[1] = 'e';ch[2] = 'l';ch[3] = 'l';ch[4] = 'o';
now, use the string class constructor and create a new string from the above array of characters −
string mychar = new string(ch);
examplelet us see the code to convert a list of characters to string in c#.
live demo
using system;namespace demo { class myapplication { static void main(string[] args) { char[] ch = new char[5]; ch[0] = 'h'; ch[1] = 'e'; ch[2] = 'l'; ch[3] = 'l'; ch[4] = 'o'; string mychar = new string(ch); console.writeline("converted to string = {0}", mychar); } }}
outputconverted to string = hello
以上就是c#程序将字符列表转换为字符串的详细内容。
其它类似信息

推荐信息