2
Answers

ConcurrentDictionary

Antonios Dev

Antonios Dev

12y
3.3k
1

 I have a question about ConcurrentDictionary.

I have the following:

public ConcurrentDictionary<String, String> myDictionary;

There are two ways of adding data.

myDictionary["SomeKey"] = "Some value"

and 

myDictionary.TryAdd("SomeKey", "Some value");

Are both method threadsafe. I mean if two processes try to access the dictionary at the same time, it will not throw an exception?

Thanks

Answers (2)