C# 只移除最后一个字符

string str = "|||";
Console.WriteLine(str.Substring(0, str.Length - 1));
Console.WriteLine(str.Remove(str.LastIndexOf("|"), 1));
Console.WriteLine(str.Remove(str.Length - 1));
注:用str.TrimEnd('|')会将所有的|都会清除!

推荐使用  Substring;

posted @ 2017-02-15 16:00  一直为你守候  阅读(242)  评论(2编辑  收藏  举报