How to add key,value pair to dictionary?.Below i have mentioned following format?
{'1_somemessage': [[3L, 1L, u'AAA', 1689544L, datetime.datetime(2010, 9, 21, 22, 30), u'gffggf'], [3L, 1L, u'BBB', 1689544L, datetime.datetime(2010, 9, 21, 20, 30), u'ffgffgfg'], [3L, 1L, u'CCC', 1689544L, datetime.datetime(2010, 9, 21, 22, 30), u'hjhjhjhj'], [3L, 1L, u'DDD', 1689544L, datetime.datetime(2010, 9, 21, 21, 45), u'jhhjjh']], '2_somemessage': [[4L, 1L, u'AAA', 1689544L, datetime.datetime(2010, 9, 21, 22, 30), u'gffggf'], [4L, 1L, u'BBB', 1689544L, datetime.datetime(2010, 9, 21, 20, 30), u'ffgffgfg'], [4L, 1L, u'CCC', 1689544L, datetime.datetime(2010, 9, 21, 22, 30), u'hjhjhjhj'], [4L, 1L, u'DDD', 1689544L, datetime.datetime(2010, 9, 21, 21, 45), u'jhhjjh']]}
You can use List<KeyValuePair<string,int>> . This will store a list of KeyValuePair 's that can be duplicate.
[C#] Dictionary with duplicate keys The Key value of a Dictionary is unique and doesn't let you add a duplicate key entry.
In Dictionary, key must be unique. Duplicate keys are not allowed if you try to use duplicate key then compiler will throw an exception. In Dictionary, you can only store same types of elements.
Add a key, value pair to dictionary
aDict = {} aDict[key] = value
What do you mean by dynamic addition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With