如何在VB.NET中使用“Into”LINQ表达式?

前端之家收集整理的这篇文章主要介绍了如何在VB.NET中使用“Into”LINQ表达式?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在转换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将g转换为Into g()本身,然后给出了这个错误

Definition of method ‘g’ is not
accessible in this context.

有任何想法吗?

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()

猜你在找的VB相关文章