Antonios Dev

Antonios Dev

  • NA
  • 39
  • 19k

ConcurrentDictionary

May 3 2012 3:23 AM

 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)