Remove duplicates in the list using linq

前端 未结 11 1641
没有蜡笔的小新
没有蜡笔的小新 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:40

    Use Distinct() but keep in mind that it uses the default equality comparer to compare values, so if you want anything beyond that you need to implement your own comparer.

    Please see http://msdn.microsoft.com/en-us/library/bb348436.aspx for an example.

提交回复
热议问题