.Contains() on a list of custom class objects

前端 未结 7 2203
天命终不由人
天命终不由人 2020-11-27 02:38

I\'m trying to use the .Contains() function on a list of custom objects

This is the list:

List CartProducts = new Lis         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 03:26

    If you want to have control over this you need to implement the [IEquatable interface][1]

    [1]: http://This method determines equality by using the default equality comparer, as defined by the object's implementation of the IEquatable.Equals method for T (the type of values in the list).

提交回复
热议问题