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 638987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:47:32+00:00 2026-05-13T20:47:32+00:00

Which one of the C# <Key, Value> structure implementations has better performance and higher

  • 0

Which one of the C# <Key, Value> structure implementations has better performance and higher speed?

P.S.1: I Have two thread, one of them writes into collection, and another one reads and writes into it.

P.S.2: Key items are random numbers, and then my access is random. Write and read actions are simultaneous.
I am using hashtable, but I want to know is there any better implementation with less resource usage and better performance?

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-13T20:47:33+00:00Added an answer on May 13, 2026 at 8:47 pm

    For profiling yourself, there are many options. One free profiler I’ve used and which I would recommend is EQATEC. There are plenty more to choose from, many of which are referenced in this SO question.

    As for implementations, the first few that pop into mind are Dictionary<TKey, TValue>, SortedDictionary<TKey, TValue> and SortedList<TKey, TValue>. Of course, I would be inclined to guess that Dictionary<TKey, TValue> is the fastest since it’s the simplest in terms of features. But I haven’t ever tested them against one another for speed.

    Note that the above classes are all generic, which should make them more efficient than HashTable in at least one sense: they do not require boxing/unboxing of keys and values as System.Object, which results in unnecessary memory allocation.

    Something else to be aware of is that since you’re in a multithreaded scenario, you’ll need to take care to lock your reads/writes somehow. (The above classes, unlike HashTable, are not guaranteed to be thread-safe for multiple readers and a writer.) Locking on a common object may be your best bet in most cases, whereas if you’re performing more reads than writes you might want to consider using a ReaderWriterLock or ReaderWriterLockSlim (both of which permit switching between multiple simultaneous readers and a single writer). If you are enumerating over the collection then you should really be locking anyway–even with a HashTable.

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since the backslash (\) is an escape character in C… May 13, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer Take a look at ORDER BY … LIMIT Performance Optimization… May 13, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer The downside of giving the customer a zip file of… May 13, 2026 at 11:00 pm

Related Questions

I have a question related to this one . I don't want to do
I've got a form inside an <asp:Content> block that is being submitted to a
I have an XML document containing types from 2 XML schemas. One (theirs.xsd) is
NOTE: This is a solution for Project Euler Problem 14 . If you still
I am trying to assign a custom type as a key for std::map .

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.