c# 删除字符串末尾一定长度字符

删除字符串末尾一定长度字符常用方法


//移除掉","
string a = "1,2,3,4,5,";
a = a.Remove(a.Length - 1, 1); 

//移除"5"和","
string s = "1,2,3,4,5,";
s = s.Substring(0, s.Length - 2);

//移除"5"和","

string s = "1,2,3,4,5,";
char[] MyChar = { '5', ',' };
s = s.TrimEnd(MyChar);

//移除全部","

string s = "1,2,3,4,5,";
s = s.Replace(",", string.Empty);

posted @ 2020-10-31 15:28  SusieSnail_SUN  阅读(502)  评论(0编辑  收藏  举报