CollectionBase and sorting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony

    #1

    CollectionBase and sorting

    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.Collecti on 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




  • Marc Gravell

    #2
    Re: CollectionBase and sorting

    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<Tand Collection<Tin place of the 1.1 CollectionBase. ..

    Marc

    Comment

    Working...