DistinctBy with two properties in VB.NET

后端 未结 1 1600
终归单人心
终归单人心 2021-01-25 15:06

Looking at Select distinct by two properties in a list it is possible to use the DistinctBy extensionmethod with two properties. I tried to convert this to vb.net, but I\'m not

1条回答
  •  有刺的猬
    2021-01-25 15:36

    You need to write Key before property. like

    New With {Key element.Id, Key element.Name} in VB.

    So,

    Result = TestList.DistinctBy(Function(element) New With {Key element.Id, Key element.Name})
    

    See the documentation for anonymous types in VB for more details.

    0 讨论(0)
提交回复
热议问题