List generic class order of items

Hi all,

The documentation about the List generic class states that the items are not guaranteed to be sorted.

However, I am after an implementation that guarantees that the items will come out of the enumerator in the same order they were added to the list instance.

Is that the case with the List generic class, or will I have to implement my own

Thanks,

SA.



Answer this question

List generic class order of items

  • juergen.b

    Mattias:

    Thanks for your answer.

    SA.


  • thomas_schmidt

    Yes the List<T> enumerator returns the items in the same order as they are in the list. So as long as they are added to the end (with Add) and not inserted into the middle of the list (with Insert) it does what you want.



  • List generic class order of items