首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

!输入一段字符的查找并替换

2012-04-07 
求助!输入一段字符的查找并替换我本初学者想用控制台程序编写一个字符查找并替换的程序,不知该从何下手求

求助!输入一段字符的查找并替换
我本初学者 
想用控制台程序编写一个字符查找并替换的程序,不知该从何下手求助~~ 
例: 
输入一段字符:i am now in usa , i found the usa is not for me , the usa is too bad ! because in the usa i can not say chinese ! 
然后我想查找字符‘usa’并且把所有的‘usa’替换成‘the beautiful usa’。 
请问如何实现?
有代码更好啦

[解决办法]
str=str.Replace("usa","the beautiful usa");
[解决办法]
str=str.Replace(@"usa",@"the beautiful usa");
这就是答案
[解决办法]
正解,不用遍历什么的,有实现好的方法了

探讨

str=str.Replace("usa","the beautiful usa");

热点排行