Trim(TrimStart)(TrimEnd) 清除字符串中首尾的空格(字符)
例如: string s1 = "http://www.2cto.com ";
string s2 = s1.Trim();
string s3 = s1.TrimStart(new char[] {'h','t','w'});
string s4=s1.TrimEnd(new char[]{' ','m'});
Console.WriteLine(s2+"隔开");
Console.WriteLine(s3);
Console.WriteLine(s4);
上述代码分别返回:http://www.2cto.com隔开
例如: string s1 = "http://www.2cto.com ";
string s2 = s1.Trim();
string s3 = s1.TrimStart(new char[] {'h','t','w'});
string s4=s1.TrimEnd(new char[]{' ','m'});
Console.WriteLine(s2+"隔开");
Console.WriteLine(s3);
Console.WriteLine(s4);
上述代码分别返回:http://www.2cto.com隔开