是否可以扩展Linq的查询关键字(例如:select、where等)以使用自定义定义?
以下是代码示例,以便更清晰地说明:
System.Collections.Generic.List<string> aList =
new System.Collections.Generic.List<string> { "aa", "ab", "ba", "bb" };
// instead of
string firstString = (from item in aList
where item.StartsWith("a")
select item).First();
// would be nice
string firstString = from item in aList
where item.StartsWith("a")
selectFirst item;
// or something else
from item in aList
where item.StartsWith("a")
WriteLineToConsole item;
我认为这不可能,但仍然抱有希望 ;)