我有以下非常简单的例子;
string MyString = "Egyptian Soccer/Egyptian Premier/Fixtures 20 January /El Shorta v El Geish";
string[] description = MyString.Split('/');
description.Select(s => s.Trim());
然而,' Fixtures 20 January'的字符串值没有删除最后的空格。
我做错了什么?
答案 0 :(得分:2)
您需要重新分配选择操作的结果
string MyString = "Egyptian Soccer/Egyptian Premier/Fixtures 20 January /El Shorta v El Geish";
string[] description = MyString.Split('/');
var result = description.Select(s => s.Trim());
foreach(string s in result)
Console.WriteLine("|" + s + "|");