Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下命令:
var sum = myList.Sum(p => p.Field);
是否可以使用 from 子句编写相同的命令?例如。
var sum = from myList ...
在这个符号中没有 sum 的表达式。这是尽可能接近的:
var sum = (from p in myList select p.Field).Sum();
是的。见下文。
Enumerable.Sum