Use extension methods:
public static class StringExtensions
{
public static string RemoveOccurences(this string s, string occurence)
{
return s.Replace(occurence, "");
}
}
using:
string s = "Remove all appearances of this and that and those";
s.RemoveOccurences("th");
source
share