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
I knocked up this quick extension method.
Not positive it works (I can't test it right now), but the theory is sound.
public static string RemoveLast(this string source, string value) { int index = source.LastIndexOf(value); return index != -1 ? source.Remove(index, value.Length) : source; }