c# - How to store a value and its list of stings in a list -


i need store value , corresponding list of strings in list. like

  key   value        2      2,3   2      4,6   4      3,5,6   should in list 

here cant use dictionary because same key might repeat. know how kindly help

use lookup. dictionary, allows same key multiple times.

here docs. have use .tolookup extension method on sequence create one.

in case, seems you'd need ilookup<string, ilist<string>> (or int instead of string, don't know data).

here's how can generate lookup:

ienumerable<keyvaluepair<string, ienumerable<string>> mydata = new[] {     new keyvaluepair<string, ienumerable<string>>("2", new[] { "2", "3" }),     new keyvaluepair<string, ienumerable<string>>("2", new[] { "4", "6" }),     new keyvaluepair<string, ienumerable<string>>("4", new[] { "3", "5", "6" }), }; var mylookup = mydata.tolookup(item => item.key, item => item.value.tolist()); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -