修改字符串 ToCharArray()

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 临时
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             //实现改变字符串
14             string s = "hello,world!";//新建字符串S并赋值
15             char[] chars = s.ToCharArray();//用s.ToCharArray()方法得到字符串的char数组
16             chars[1] = 'i';//对chars数组进行修改
17             s = new string(chars);//调用new string(char[])这个构造函数来创建char数组的字符串
18             Console.WriteLine(s);
19             Console.ReadKey();
20 
21         }
22     }
23 }
原文地址:https://www.cnblogs.com/start-from-scratch/p/5050040.html