Re: A dictionary with many keys for the same value
- From: Rick Lones <WrlonesX@xxxxxxxxxxxxx>
- Date: Thu, 12 Oct 2006 22:31:21 -0400
Dustin Campbell wrote:
Your stated requirement appears contradictory since your example code
does in fact add two items. Do you mean that you want to "rewrite"
the key (from 0 to 11 in this case)? In that case the technique would
be to remove the item with key == 0, then add it back with key == 11.
This does of course add the item twice, however the resulting
collection.Count would be 1 as desired.
I think he was pretty clear. The example code adds the same item twice but with different keys. He wants the collection to contain two keys pointing to the same item so that the isn't a one-to-one relationship between a key and the item.
Having multiple keys reference the same value is easy enough - but there is an apparent contradiction in wanting the resulting dictionary to have a count of 1. What he really wants the count to indicate, apparently, is the number of unique values in the collection.
Regards,
-rick-
.
- References:
- Re: A dictionary with many keys for the same value
- From: Rick Lones
- Re: A dictionary with many keys for the same value
- From: Dustin Campbell
- Re: A dictionary with many keys for the same value
- Prev by Date: If a DataGrid.DataSource is an IList, not a DataTable, is there a way similar to dt.AcceptChanges(), dt.RejectChanges()
- Next by Date: Re: VS command prompt vs Windows one?
- Previous by thread: Re: A dictionary with many keys for the same value
- Next by thread: Deadlock in multithread C# app
- Index(es):
Relevant Pages
|