我不明白为什么代码A是正确的和代码B不正确:了解LINQ查询 - 排序依据上升
码A
IEnumerable<decimal> loanQuery =
from amount in loanAmounts
where amount % 2 == 0
orderby amount
select ascending amount //this line
代码B(不正确)
IEnumerable<decimal> loanQuery =
from amount in loanAmounts
where amount % 2 == 0
select amount
orderby ascending amount
由于很多人的回答都不正确,我现在发布了正确的代码:
IEnumerable<decimal> loanQuery =
from amount in loanAmounts
where amount % 2 == 0
orderby amount ascending
select amount
因为您需要用select完成查询。 – Maarten 2013-05-03 09:05:06
在编程语言中有一种叫做语法的东西 – Cris 2013-05-03 09:05:47
http://msdn.microsoft.com/en-IN/library/bb397678.aspx – Freelancer 2013-05-03 09:06:13