Can I do something like following to remove specific strings from the end of the words ?
public static HashSet<string> stringtoremove = new HashSet<string>
...............
.................
public static string stepone(this string word)
{
if (stringtoremove(word.EndsWith))
{
word = ..................................;
}
return word;
}
I tried but it doesn’t work. did i miss something in my code ? thanks in advance.
I assume that you actually want to look into the
HashSet<String>to see if the given string parameter ends with one of these words. If so, remove it from the end of the string.You can use
FirstOrDefaultto determine the first string in the set that is also the end of the given word: