C# 中的 TrimEnd() 方法
csharpprogrammingserver side programming更新于 2025/9/24 8:37:17
TrimEnd() 方法用于删除数组中指定字符集的所有尾随字符。
例如,以下字符串包含尾随的 1。
String str ="234561111".
我们可以使用 TrimEnd() 方法轻松地从字符串中删除上述尾随的 1。
让我们看一个删除所有尾随 1 的示例。
示例
using System;
class Program {
static void Main() {
String str ="234561111".TrimEnd(new Char[] { '1' } );
Console.WriteLine(str);
}
}
输出
23456

