C# TrimEnd() 方法用于从当前 String 对象中删除数组中指定的一组字符的所有尾随出现。
声明
public string TrimEnd(params Char[] ch)
参数
ch:它需要一个字符数组作为参数。
返回
它返回一个字符串。
C# String TrimEnd() 方法示例
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";
char[] ch = {'#'};
string s2 = s1.TrimEnd(ch);
Console.WriteLine(s2);
}
}
输出:
Hello C