Dictionary

from https://stackoverflow.com/questions/11557418/difference-of-dictionary-add-vs-dictionarykey-value


Dictionary


Add -> Adds an item to the dictionary if item already exists in the dictionary an exception will be thrown.
Indexer or Dictionary[Key] => Add Or Update. If the key doesn't exist in the dictionary, a new item will be added. If the key exists then the value will be updated with the new value.


from https://stackoverflow.com/questions/139592/what-is-the-best-way-to-clone-deep-copy-a-net-generic-dictionarystring-t

Copy
Dictionary<string, int> dictionary = new Dictionary<string, int>();

Dictionary<string, int> copy = new Dictionary<string, int>(dictionary);

留言

熱門文章