Yes, maybe here are the conditions ( from MSDN ):
- ArgumentNullException - when the key is a null reference
- OverflowException - when the maximum number of items has been reached
- Returns false if an item with the same key already exists.
Just to repeat, this has nothing to do with concurrency. If you are worried about two threads inserting an element at the same time, the following may happen:
- Both inserts work fine if the keys are different.
- One insert works fine and returns true, another insert fails (without exception) and returns false. This happens if two threads try to insert an element with the same key, and basically only one wins and the other loses.
oleksii Jul 16 2018-12-12T00: 00Z
source share