I need this all the time and am constantly frustrated that the Trim(), TrimStart() and TrimEnd() functions don\'t take strings as inputs. You call EndsWith() on a string, an
EDIT - wrapped up into a handy extension method:
public static string TrimEnd(this string source, string value) { if (!source.EndsWith(value)) return source; return source.Remove(source.LastIndexOf(value)); }
so you can just do s = s.TrimEnd("DEF");
s = s.TrimEnd("DEF");