案例:删除字符串中的最后一个字符
string s = "8,2,3,7,9," //处理后变成 “8,2,3,7,9”
方法一:使用Substring
string s = "8,2,3,7,9,"
s = s.Substring(0,s.Length - 1)
方法二、用TrimEnd,这个方法传递的是一个字符数组
string s = "8,2,3,7,9,"
s=s.TrimEnd(',')
//如果要删除"9,",则需要这么写
char[] MyChar = {'9',','};
s = s.TrimEnd(MyChar);
方法三、用Remove
string s = "8,2,3,7,9,"
s = s.Remove(a.Length - 1,1); //移除掉","