我正在转换C#这个LINQ表达式。但是,它似乎不起作用。
C#
return (from w in fishSticks
group w by w.FishQty into g
orderby g.Key descending
select g).First().First();
VB
Return (From w In fishSticks
Group w By w.FishQty Into g()
Order By g.Key Descending
Select g).First().First()
Visual Studio将Into g
转换为Into g()
本身,然后给出了这个错误:
方法'g'的定义不是 在这种情况下可以访问。
有什么想法吗?
答案 0 :(得分:12)
VB.Net has different group syntax
正确的语法是
Dim q = (From w In fishSticks
Group By Quantity = w.FishQty Into g = Group
Order By Quantity Descending
Select g).First().First()