.net Value Class sorting with IComparable
Posted
by greggorob64
on Stack Overflow
See other posts from Stack Overflow
or by greggorob64
Published on 2010-04-21T14:48:21Z
Indexed on
2010/04/21
14:53 UTC
Read the original article
Hit count: 406
I'm running into an issue using a DataGridView
bound to a iBindingListView
implementation (third party dll) attached to a large collection.
There's a certain property in my collection type, named MyDateTime
, which is a value class similar to DateTime, but also with some legacy code.
This VALUE CLASS implements iComparable
, iComparable<T>
, and iEquatable<T>
.
The issue I'm having is this:
When I apply a sort to the iBindingListView
, or the Automatic Sorting provided by the DGV on the MyDateTimeColumn
, it ALWAYS uses the non-generic iComparer
, causing hundreds of thousands of unnecessary boxing and unboxing.
When I remove the non-generic iComparer, the generic one is still not used, it just does a string compare on the .ToString().
Am I missing something? Why is my generic comparer not bieng called on a sort?
© Stack Overflow or respective owner