CollectionBase and sorting

T

Tony

Hello!

I'm reading a book and here I have found something that sounds strange.
It says the following:
"Note that some classes in the System.Collection namespace, including
CollectionBase, don't
expose a method for sorting. If you want to sort a collection you have
derived from this class you''ll
have to put a bit more work in and sort the internal List collection
youself."

So assume I have derived a class from this CollectionBase I can use either
the List or InnerList to sort by objects
that is implementing either CompareTo or Compare.

My question is what exactly do they mean in the text above with "you''ll
have to put a bit more work in and sort the internal List collection
youself."

//Tony
 
M

Marc Gravell

Indeed it looks like you should be able to just use InnerList.Sort() -
although note that I would recommend using the generic classes like
List<T> and Collection<T> in place of the 1.1 CollectionBase...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top