c# - What structure involving Key and Value pair should be adopted when both Key and Value are repeated? -


what structure involving key , value pair should adopted when both key , value repeated?

scenario: generating anonymous type in wpf way

var result = enum.getvalues(typeof(key)).cast<key>()                  .select(x => new {key = x, value = (int)x}); 

i tried converting dictionary using

.todictionary(key => key, value => (int)value); 

or

.todictionary(key => (int)key, value => value); 

but in both cases gives exception an item same key has been added. means keys repeated in both cases.

now structure should adopted in scenario? should go keyvaluepair<int, key>[] or other?

personally i’d stick dictionary<tkey, list<tvalue>> if want fancier interface might want write own multimap wrapper class that.

of course, in neither case can use todictionary since uses existing unique-key dictionary internally can write own tomultimap extension method.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -