首页 > 其他 > 详细

修改字符串 ToCharArray()

时间:2015-12-16 09:34:00      阅读:175      评论:0      收藏:0      [点我收藏+]
 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 }

 

修改字符串 ToCharArray()

原文:http://www.cnblogs.com/start-from-scratch/p/5050040.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!