Distinct in LINQ with anonymous types (in VB.NET)

后端 未结 5 1455
醉梦人生
醉梦人生 2020-12-16 20:29

Supposing the referenced List below contains 2 elements:

Dim Countries = From c In List _
                Select New With { .Country = c.Country         


        
5条回答
  •  生来不讨喜
    2020-12-16 21:05

    There is the LINQ operator named Distinct(), which you can call like so:

     Dim Countries = (From c In List _
                 Select c.Country, c.CountryID).Distinct()
    

    More information on Distinct here

提交回复
热议问题