Reversing ObservableCollection <objectType> using linq
It should be easy, and I am ashamed that I have not figured it out yet. I am trying to reorder the list of items in my wp7 application. A list is an ObservableCollection. When using system.linq, intellisense allows me to do this: myList.Reverse (); but this does not seem to work. Am I doing something wrong, or can I do it another way?
Thanks in advance.
+5
3 answers
The reverse returns IEnumerable; it does not modify the collection. To change the collection you can do
collection = new ObservableCollection<YourType>(collection.Reverse());
+23