I have a dictionary like
public Dictionary<DateTime, Dictionary<string, string>> dicCollection
How can I add more values to the same key in this dictionary?
Using C# 3.0
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re trying to add values to the outer dictionary in your example, you could use code like this:
That will ensure that when a new key gets added to the outer dictionary, the inner dictionary won’t be null (if it were null, calling Add would throw a null reference exception).