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

shark223222 2012-03-21 05:54:56
我本初学者
想用控制台程序编写一个字符查找并替换的程序,不知该从何下手求助~~
例:
输入一段字符: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’。
请问如何实现?
有代码更好啦
...全文
44 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
色拉油 2012-03-21
  • 打赏
  • 举报
回复
正解,不用遍历什么的,有实现好的方法了
[Quote=引用 1 楼 q107770540 的回复:]

str=str.Replace("usa","the beautiful usa");
[/Quote]
EnForGrass 2012-03-21
  • 打赏
  • 举报
回复
str=str.Replace(@"usa",@"the beautiful usa");
这就是答案
q107770540 2012-03-21
  • 打赏
  • 举报
回复
str=str.Replace("usa","the beautiful usa");

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧