Trim 不删除多个空格
Trim Not Removing Multiple White Spaces
我有以下非常简单的例子;
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 ' 的字符串值并没有在末尾删除空格。
我做错了什么?
您需要重新分配 Select 操作的结果
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 + "|");
我有以下非常简单的例子;
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 ' 的字符串值并没有在末尾删除空格。
我做错了什么?
您需要重新分配 Select 操作的结果
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 + "|");