DateTime as key in SortedDictionary <K, V>
3 answers
You will not need a new IComparer. your default IComparer will use GetHashCode () from your value object and compare / sort with it. Since the DateTime type correctly implements GetHashCode (), by default, IComparer will sort as you wish (for example, you find).
Creating a new mapping is more for complex collections that you may have written yourself. I wrote a complex comparator once. it is a bit tiring.
+7
I work well because DateTime implements IComparable<DateTime> . So you can rely on Comparer (T) .Default .
Inside, DateTime uses ticks to compare two dates.
+9