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
Regex replace may be your friend in this instance.
var str = "Hello World!"; str = Regex.Replace(str, @"World!$", ""); //str == "Hello"