What are the differences between a list, sorted list, and an array list? (c#)

ChocolateSnow picture ChocolateSnow · Oct 29, 2015 · Viewed 11.6k times · Source

From what I've read, a list, sorted list, and an array list have many things in common, but at the same time have a few differences.

I would like to know: What are the differences between them that a beginner should know? Why choose one over the other? And what are some good habits to form when using them in code?

Thank you for your time.

Answer

user1968030 picture user1968030 · Oct 29, 2015

From MSDN:

A SortedList element can be accessed by its key, like an element in any IDictionary implementation, or by its index, like an element in any IList implementation.

A SortedList object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values. Each element is a key/value pair that can be accessed as a DictionaryEntry object. A key cannot be null, but a value can be.

Also for choosing best collection you can see this.

enter image description here