Remove duplicates in the list using linq

前端 未结 11 1457
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 03:04

I have a class Items with properties (Id, Name, Code, Price).

The List of Items is populated with duplicated items.

F

11条回答
  •  忘了有多久
    2020-11-22 03:31

    If there is something that is throwing off your Distinct query, you might want to look at MoreLinq and use the DistinctBy operator and select distinct objects by id.

    var distinct = items.DistinctBy( i => i.Id );
    

提交回复
热议问题