string.Trim(char[])函数没有起任何作用,为什么?
下面这一段程序:
string s = " abc esdf ";
char[] sz = { ' ', 'e' };
string snew = s.Trim(sz);
Console.WriteLine(snew+","+s);
string s = " eabc esdfe ";
char[] sz = { ' ', 'e' };
string snew = s.Trim(sz);
Console.WriteLine(snew+","+s);
string s = " abc esdf ";
char[] sz = { ' ', 'e' };
string[] snew = s.Split(sz, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in snew)
{
Console.WriteLine(item);
}
string s = " abc esdf ";
char[] sz = { ' ', 'e' };
string snew = System.Text.RegularExpressions.Regex.Replace(s,@"[\se]*","");
Console.WriteLine(snew);