字符串:string s = "1,2,3,4,"
实现效果:删除最后一个 ","
方法:
1.用Substring
s = s.Substring(0,s.Length - 1)
2.用 RTrim
s = s.ToString().RTrim(',')
3.用TrimEnd
s=s.TrimEnd(',')
//如果要删除"4,",则需要这么写
char[] MyChar = {'4',','};
s = s.TrimEnd(MyChar);
//s = "1,2,3
4.用lastIndexOf()和deleteCharAt()
int index = sb.toString().lastIndexOf(',');
sb.deleteCharAt(index);