我一直在阅读有关 c# 的 LINQ 功能并遇到以下代码:
List<string> myFruitList = new List<string>() {
"apple", "plum", "cherry", "grape", "banana", "pear", "mango" ,
"persimmon", "lemon", "lime", "coconut", "pineapple", "orange"};
var results = from e in myFruitList
where e[0] == 'p' || e[0] == 'l'
group e by new {
FirstChar = e[0],
LengthGt5 = e.Length > 5 //no type mentioned for FirstChar and LengthGt5
};
我无法理解的是FirstChar
(char)和LengthGt5
(bool)字段没有提到类型。我很困惑。请解开疑惑。提前致谢。