
首先,声明字符数组并设置每个字符的值 −
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 −
10分钟内自己学会PHP其中,第1篇为入门篇,主要包括了解PHP、PHP开发环境搭建、PHP开发基础、PHP流程控制语句、函数、字符串操作、正则表达式、PHP数组、PHP与Web页面交互、日期和时间等内容;第2篇为提高篇,主要包括MySQL数据库设计、PHP操作MySQL数据库、Cookie和Session、图形图像处理技术、文件和目录处理技术、面向对象、PDO数据库抽象层、程序调试与错误处理、A
524
string myChar = new string(ch);
Let 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);
}
}
}Converted to string = Hello
以上就是C#程序将字符列表转换为字符串的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号