Failed to compare two elements in the array

前端 未结 5 2052
滥情空心
滥情空心 2020-12-11 00:01

I have a List where T is a class that exposes a \"Username\" property. Username is of a custom type that encapsulates a string. I implemen

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 00:16

    your answer isn't strictly correct from what I can tell. My objects don't implement IComarable or IComparable at all and they still work fine. I am creating a CollectionViewSource and adding sort descriptions just like you and not getting this error. I was getting the error because the property in the sort description was blank. Once I fixed this everything worked fine without the interface. I suspect maybe you had a property incorrect and it drops back to using IComparable if it can't access the property.

提交回复
热议问题