If i wish to put items into a System.Collections.Generic.Dictionary, I can either Add or set the Item.
I know if we do Add it checks if the key already exists and if not it throws an exception.
So when adding a ton of items, should I prefer setting Item instead of Add, since Add does unnecessary checks that may actually slow things down?
Here is what happens when you set Item:
Here is what happens when you add item:
The last parameter last bool
addparameter just affects this line:So if you want exception when you add a duplicate item, you need to use Add. If you want to overwrite exiting item you need to set Item.