我可以执行类似以下的操作来从单词的末尾删除特定的字符串吗?从单词c的末尾删除特定的字符串#
public static HashSet<string> stringtoremove = new HashSet<string>
...............
.................
public static string stepone(this string word)
{
if (stringtoremove(word.EndsWith))
{
word = ..................................;
}
return word;
}
我试过了,但它不起作用。我错过了我的代码中的东西吗?提前致谢。
*你究竟做了什么? –
您需要更精确地指定您的要求。订购将很重要。例如,如果'stringtoremove'(可怕的名字,btw - 遵循.NET命名约定)包含“ab”和“xy”,那么如果给它“123abxy”,结果应该是什么?那么“123xyab”呢? –
@ mudu,匹配每个单词的末尾,如果它包含其中的一个字符串,则将它们移除。 –