The TrimEnd() method removes all trailing occurrences of a set of characters specified in an array.
For example, the following string has trailing 1s.
String str ="234561111".
We can easily remove the above trailing 1s from a string using the TrimEnd() method.
Let us see an example to remove all trailing 1s.
Example
using System;
class Program {
static void Main() {
String str ="234561111".TrimEnd(new Char[] { '1' } );
Console.WriteLine(str);
}
}Output
23456