© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•7mo ago•
38 replies
nathanAjacobs

Concurrent collection type similar to Dictionary<TKey, List<TValue>>

For example, I don't think
ConcurrentDictionary<string, List<string>>
ConcurrentDictionary<string, List<string>>
or even
ConcurrentDictionary<string, ConcurrentBag<string>>
ConcurrentDictionary<string, ConcurrentBag<string>>
would be thread safe when accessing one of the lists.

The simplest solution would be to lock whenever accessing the dictionary, but I was wondering if there is a better solution?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Data structure in C# - Dictionary<TKey, TValue>
C#CC# / help
12mo ago
❔ Having trouble with binding Dictionary<TKey, TValue>
C#CC# / help
4y ago
How to perform LINQ Average against collection of TValue constrained as INumber<TValue>
C#CC# / help
3y ago
Is there a concurrent ordered collection?
C#CC# / help
4y ago