C# Can';t将其转换为VB.net

C# Can';t将其转换为VB.net,c#,vb.net,linq,c#-to-vb.net,C#,Vb.net,Linq,C# To Vb.net,我正在尝试将以下内容转换为vb.net。提前谢谢 Categories.DataSource = objDT.Rows.Cast<DataRow>() .Select(r => new { Attendee = r.Field<string>("Attendee"), Item = r.Field<string>("Item") }) .GroupBy(v => v.Attendee) .Sel

我正在尝试将以下内容转换为vb.net。提前谢谢

   Categories.DataSource = objDT.Rows.Cast<DataRow>()
        .Select(r => new { Attendee = r.Field<string>("Attendee"), Item = r.Field<string>("Item") })
        .GroupBy(v => v.Attendee)
        .Select(g => new { Attendee = g.Key, Item = g.ToList() });

试试下面的方法

Categories.DataSource = objDT.Rows.Cast(Of DataRow)() _
    .Select(Function(r) New With {.Attendee = r.Field(Of String)("Attendee"), .Item = r.Field(Of String)("Item")}) _
    .GroupBy(Function(v) v.Attendee) _
    .Select(Function(g) New With { .Attendee = g.Key, .Item = g.ToList()})
试试这个:

  Categories.DataSource = objDT.Rows.Cast(Of DataRow)().Select(Function(r) New With { _
 .Attendee = r.Field(Of String)("Attendee"), _
 .Item = r.Field(Of String)("Item") _
}).GroupBy(Function(v) v.Attendee).Select(Function(g) New With { _
 .Attendee = g.Key, _
 .Item = g.ToList() _
})
对象类(带{}的新对象()与匿名类型(带{}的新对象)不同


您以后可以使用此网站:。它对大多数转换都很有效。

谢谢Matthieu,这种方法很有效!我会记得尝试上面的转换链接。谢谢JaredPar,你的解决方案也同样有效!我也可以给你绿色的复选标记。谢谢:)
Categories.DataSource = objDT.Rows.Cast(Of DataRow)() _
    .Select(Function(r) New With {.Attendee = r.Field(Of String)("Attendee"), .Item = r.Field(Of String)("Item")}) _
    .GroupBy(Function(v) v.Attendee) _
    .Select(Function(g) New With { .Attendee = g.Key, .Item = g.ToList()})
  Categories.DataSource = objDT.Rows.Cast(Of DataRow)().Select(Function(r) New With { _
 .Attendee = r.Field(Of String)("Attendee"), _
 .Item = r.Field(Of String)("Item") _
}).GroupBy(Function(v) v.Attendee).Select(Function(g) New With { _
 .Attendee = g.Key, _
 .Item = g.ToList() _
})