Split、Substring、Replace的综合用法:string bb="中国人, 历史, 前途, 第四, opq, rst, uvw, xyz";
string cc="";
cc=bb.Replace(", ",",");
string[] renshushu=cc.Split(',');
int renshu=renshushu.Length;
string zh="xyz";
int inof=cc.IndexOf(zh);
string zuo="",you="",he="";
if (inof!=-1)
{
if(inof==0)
{ he=cc.Substring(zh.Length+1);}
else if(inof+zh.Length==cc.Length)
{he=cc.Substring(0,inof-1);}
else
{
zuo=cc.Substring(0,inof);
you=cc.Substring(inof+zh.Length+1);
he=String.Concat(zuo,you).ToString();
}
}
Label3.Text="renshu:"+renshu+"<br>"+zuo+"<br>"+you+"<br>"+he;
刚刚解决这个问题