Replace 字符串替换
单个替换:
string str = "aaaaaaa#bbbbbb#aaaaaa";
替换#bbbbbb#为cccccc
String ii = str.Replace("#bbbbbb#", "cccccc");
MessageBox.Show(ii.ToString());
多重替换:
string str="aaaaa#bbbbb#aaaaaa#cccccc#aaaaa";
替换#bbbbbb#为dddddd
#ccccccc#为eeeeeee
String ii = str.Replace("#bbbbbb#", "dddddd").Replace("#ccccccc#", "eeeeeee");
MessageBox.Show(ii.ToString());
string str = "aaaaaaa#bbbbbb#aaaaaa";
替换#bbbbbb#为cccccc
String ii = str.Replace("#bbbbbb#", "cccccc");
MessageBox.Show(ii.ToString());
多重替换:
string str="aaaaa#bbbbb#aaaaaa#cccccc#aaaaa";
替换#bbbbbb#为dddddd
#ccccccc#为eeeeeee
String ii = str.Replace("#bbbbbb#", "dddddd").Replace("#ccccccc#", "eeeeeee");
MessageBox.Show(ii.ToString());