【发布时间】:2009-03-04 19:24:54
【问题描述】:
谁能想到一种有效的方法(时间方面)从字符串中间修剪几个选定的字符?
我想到的最好的是:
public static string Trim(this string word, IEnumerable<char> selectedChars)
{
string result = word;
foreach (char c in selectedChars)
result = result.Replace(c.ToString(), "");
return result;
}
但还是太慢了。
【问题讨论】:
标签: c# .net performance string