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;
本文共 269 字,大约阅读时间需要 1 分钟。
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;
转载于:https://www.cnblogs.com/luluit/p/6401818.html