Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 129269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:45:54+00:00 2026-05-11T05:45:54+00:00

Most of my programming experience is in a language where there is one collection

  • 0

Most of my programming experience is in a language where there is one collection data structure — an array. Now that I’m working primarily in .NET, I’ve come to appreciate the vast number of tools available to me, but I also find it difficult to determine which tools is best suited for each problem. I find this to be the case often with collections.

I’m sure I’ll be able to spot the right tool for the job quicker with time/experience, but can anyone offer some guidance on which collection classes are good for which jobs? Any good rules of thumb to follow?

EDIT: I find that I use List(T) almost always, which is sort of what prompted this question. I know there are very specific reasons to use the other classes. Although List(T) works most times, I want to avoid jamming something into a generic list when another structure is better suited. I have to be able to spot these cases.

Thanks!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:45:55+00:00Added an answer on May 11, 2026 at 5:45 am

    You didn’t say what language you used before, but I feel pretty confident in saying that if you believe that array was the only thing available, then you were probably mistaken.

    C++ for example only supports array ‘collections’ natively (‘collections’ used very loosely here), but with the addition of pointers you can implement an equivalent for any collections data structure available in .Net. In fact, if you look in the C++ standard template library you will find stock implementations for most of the common structures.

    The reason for the additional structures is that an array is not always, or even often, the most appropriate structure to use for a collection of data. It has a number of limitations that can be solved by one collection or another, and using those different collections you can often get much greater performance out of much less code, and reduce the chance there’s a bug in your data structure implementation as well.

    When deciding what collection type to use, you need to look at how it will be used most ofen. For example, are all the objects in the collection expected to be of the same type, inherited from the same type, or any type? Are you going to be frequently adding and removing items? If so, will you always push/pop, queue/dequeue items or do you need to add items to specific locations? Will you lookup specific items by key, by index, or both? If by key, how is the key determined?

    Some of the more common collections:

    • List<T> should probably be used in most of the situations where you’re used to using an array. It supports lookup by index using the same syntax as an array with performance approaching that of an array, is strongly-typed, and makes it very easy to add or remove items and very fast to append or pop items (inserting to a specific position is much slower).

    • LinkedList<T> should sound familiar if you’ve done any formal computer science training. It uses syntax similar to List, but is optimized differently: lookups are slower because they require traversing the list, while adding or removing an item to a specific position can be much faster.

    • Dictionary<TKey, TValue> uses syntax similar to a List<T>, but instead of an array index you put a key value in the brackets. Dictionaries are great because lookups of specific items by key are considered to be very fast, in that no matter how many items are in the Dictionary it will always take about the same amount of time to find the one you need.

    • SortedList<TKey, TValue> works much a like a Dictionary, with the exception that when you iterate over it items are returned sorted by key. However, you can’t lookup the nth item without first iterating all the items before it.

    • KeyedCollection is often overlooked because it’s hidden in a different namespace from some of the other collections and you have to implement a (very easy) function to use it. It also works much like a dictionary, with the addition that it supports easy lookup by index. It is normally used when the key for an item is a simple property of the item itself.

    • Don’t forget the old standbys: Stack and Queue. Again, if you have any formal computer science education at all you should already have a pretty good idea how those work based on their names.

    Finally, most of these collections (array included!) implement a set of common interfaces. These interfaces are very useful, in that you can write a program against an interface rather than a specific collection, and then your function can accept any collection that implements that interface. For example, the following code will work whether you pass in a string array, a List<string>, or any other IEnumerable<string>:

    void WriteToConsole(IEnumerable<string> items) {     foreach (string item in items)     {        Console.WriteLine(item);     } } 

    Other interfaces worth looking at include IList<T>, ICollection<T>, and IQueryable<T>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most of my programming experience has either been using forms (Windows Forms, or ASP.NET)
What algorithm taught you the most about programming or a specific language feature? We
This is probably one of the most common tasks / problems when programming; You
In most programming languages, dictionaries are preferred over hashtables. What are the reasons behind
In general I think I can convey most programming related concepts quite well. Yet,
It seems like in most mainstream programming languages, returning multiple values from a function
Unquestionably, I would choose to use the STL for most C++ programming projects. The
I have worked on single threaded business logic/back-end programming for most of my career.
I create business applications with heavy database use. Most of the programming work is
What kind of programming problems are state machines most suited for? I have read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.