我不明白爲什麼代碼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