Answer: When we run above code,then it will throw an error saying that
An item with the same key has already been added.
Because we know that Dictionary have Unique key,it can not be Duplicate.
Always check if key is duplicate:
if (!dict_names.ContainsKey("Key"))
{
//add keys into Dictionary
}
Asked In: Many Interviews |
Alert Moderator