是否可以使用自己的定義擴展Linq的查詢關鍵字(如:select,where等)?是否可以在C#/ LINQ中擴展查詢關鍵字?
Codeexample這樣可以很清楚:
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;
我認爲這是不可能的,但仍然希望;)來實現,這將是寫一個預處理器,這將改變您的自定義
任何特定的原因,你爲什麼要這樣做? – AakashM
三位400K +用戶回答了你的問題。去吧,宰一隻山羊! – dotNET