From: cate on
Is there a switch somewhere, or a different hash, that will allow me
to add the same key again and again with out throwing?
Thank you.
From: Family Tree Mike on
On 5/9/2010 12:16 PM, cate wrote:
> Is there a switch somewhere, or a different hash, that will allow me
> to add the same key again and again with out throwing?
> Thank you.

If you had two keys named "FindMe", one pointing to "Fred", one pointing
to "Barney", then how would code know which to return for MyDictionary
["FindMe"]?

There actually is a trick, but to use the trick, you would need to have
a good explanation as to why you want duplicate strings as keys.

--
Mike
From: Arne Vajhøj on
On 09-05-2010 12:16, cate wrote:
> Is there a switch somewhere, or a different hash, that will allow me
> to add the same key again and again with out throwing?

The term Add indicates that a new entry is added. If a new entry
is not added, then it seems rather fair that an exception is
thrown.

The syntax:

dic[key] = val;

allows you to both add and update with the same syntax.

Note that this syntax does not in current implementation
do a test and a remove if already exists - both Add and
this set calls the same private Insert method which determines
whether to throw an exception or update the value based on a flag
passed on to it.

Arne