System.Collections.Generic.Dictionary vs System.Collections.Generic.List

Posted on 2011-10-03
Last Modified: 2013-12-16
Is there any buddy you help me out. i am trying looking about the which i more efficient or fast between these 2 System.Collections.Generic.Dictionary vs System.Collections.Generic.List
Question by:sachin233
    LVL 40

    Accepted Solution

    The only way know which is faster between 2 different type of objects is to test both.

    There are too many variables. Maybe a Dictionary of Strings will be faster than a List of Strings, but a Dictionary of Bitmap might be slower than a List of Bitmap.

    Maybe adding data to the Dictionnary will be faster, but removing for a List will be faster.

    Each type of variable and each type of operation might go its own way as far as performance in concerned.

    Note also that each has a different use. So the way you use them has an impact on your decision.

    A List is limited to an access through a numeric key: x(1)

    A Dictionary lets you specify the type of the key, so yo migth endup with: x("City") or x(Date.Today), wich might make more sense to you than x(1), depending on how the collection is used.

    Now, if you key is an Integer, I bet that a List would be faster, because it was built from the ground around an Integer key, while the Dictionary was built with any type of value as the key. But who knows until it has been tested for your conditions.

    Since both have basically the same properties and methods, you can easily test them both with the same code. So making comparisons is just a matter of a few minutes of testing, in your environment, with your type of data, with the kind operations you are most likely to do with them.

    LVL 12

    Expert Comment


    If you are doing lots of lookups, use a dictionary instead of a list:

    Good discussion of lots of data collection types here:

    Author Closing Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now