Does anyone know a good resource to concisely explain the different types of lists available in C# and when their usage is appropriate?
For example, List, Hashtable, Dictionaries etc.
I’m never quite sure when I should be using what.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
These aren’t all lists, although they’re all collections. Here’s a quick summary.
Non-generic collections (API is in terms of
object. Values types are boxed.These are mostly in the System.Collections namespace:
Generic collections. (Strongly-typed API, will not box value types (assuming suitable T).
These are mostly in the System.Collections.Generic namespace:
Possibly the most important collection interface is IEnumerable (and IEnumerable<T>). This represents a sequence of items much like a Stream represents a sequence of bytes. There is no random access, just forward-reading. LINQ to Objects is based on this, and pretty much all collection types implement it.