我正在转换一个c#LINQ示例:
var query = from m in typeof(string).GetMethods()
where m.IsStatic == true
orderby m.Name
group m by m.Name into g
orderby g.Count()
select new { name = g.Key, overloads = g.Count() };
在上面的C#中,g是一个IGrouping,但是在VB下面它取而代之的是IEnumerable,因此g.Key没有解析。
Dim query = From m In GetType(String).GetMethods() _
Where m.IsStatic = True _
Order By m.Name _
Group m By m.Name Into g = Group _
Order By g.Count _
Select name = g.Key, [overloads] = g.Count()
我如何在VB中执行此操作?
答案 0 :(得分:1)
我认为你想要的是:
Dim query = From m In GetType(String).GetMethods() _
Where m.IsStatic = True _
Group m By m.Name Into g = Group _
Order By Name, g.Count _
Select New With {.MethodName = Name, .Overloads = g.Count()}
希望有所帮助。