Sorted Dictionary / List woes.

"Bhatnagar, Amit" <[email protected]> Tue, 13 Nov 2007 08:16:02 -0700
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
Hi All.

I have a problem that I think a
System.Collections.Generic.SortedList/Dictionary can solve, but I am
unable to get it to work.

I want to store a list of messages in a collection where I can check if
an entry already exists quickly (dictionary), but also be able to return
these messages in chronological order - so I thought a SortedDictionary
is what I wanted to do here.

So I create it like SortedDictionary<long, MessageInfo> where
MessageInfo is a class that contains all the required info of a message,
and the long key is a unique identifier so I know if I am adding
duplicates.

Now what I wanted to do is create a IComparer<> on the DateTime within
the MessageInfo so that the SortedDictionary would use that to sort, but
it seems that the IComparer I make has to work on the type of the key
(in this case, long), or it won't complile. I guess it is only ment to
sort the keys of the key/value pair.

Does anyone know what else I could do so I can have a collection that is
keyed on a unique ID, but also have the ability to return these values
in chronological order?

thanks.


The information contained in this e-mail message is PRIVATE. It may contain confidential information and may be legally privileged. It is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any dissemination, distribution or reproduction of this communication is strictly prohibited. If the intended recipient(s) cannot be reached or if a transmission problem has occurred, please notify the sender immediately by return e-mail and destroy all copies of this message. 
Thank you.