List.Contains is not working as hoped

前端 未结 4 1130
[愿得一人]
[愿得一人] 2020-12-06 08:28

If I have an object of type MyBull and a List orig:

// Just an example
MyBull x = getMeTheObjectWithIdFromDB(9);

ori         


        
4条回答
  •  自闭症患者
    2020-12-06 08:54

    By default objects will expose reference based equality. If you want custom rules, such as equality based on id fields, you need to override the Equals and GetHashCode methods.

提交回复
热议问题