导航

在字符串中替换指定的子字符串

Posted on 2010-07-02 16:05  ykhi  阅读(720)  评论(0)    收藏  举报

string MyString = "中华人民共和国";
string MyInfo = "\n替换前:" + MyString;
 //显示“中华民国”
MyInfo += "\n替换后:" + MyString.Replace("华人民共和", "华民");           
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);