What happens when you try to insert a duplicate key into a Dictionary?
- Using Add() will throw a System.ArgumentException
- Using the indexer (dictionary[key] = value) will overwrite the existing value
Example:
dictionary.Add("John", 25);
dictionary.Add("John", 30); // Exception
dictionary["John"] = 30; // Overwrites the value safely