字符串:string s = "1,2,3,4,5,"
目标:删除最后一个 ","
方法:
1、用的最多的是Substring,这个也是我一直用的
s = s.Substring(0,s.Length - 1)
2、用TrimEnd,这个东西传递的是一个字符数组
s=s.TrimEnd(‘,‘)
//如果要删除"5,",则需要这么写
char[] MyChar = {‘5‘,‘,‘};
s = s.TrimEnd(MyChar);
//s = "1,2,3,"
3、用Remove
string a = "123";
a = a.Remove(a.Length - 1,1); //移除掉","