Hello,
I'd like to create a Dictionary, the TKey is a string and the TValue is a List<DateTime>
How can I do this ?
Thanks,
Hello,
I'd like to create a Dictionary, the TKey is a string and the TValue is a List<DateTime>
How can I do this ?
Thanks,
Dictionary<string, List<DateTime>> dict = new Dictionary<string, List<DateTime>>();
Note that, when adding new items, you need to allocate a new list for the value:
string key; // assuming that's your key
List<DateTime> value;
if (!dict.TryGetValue(key, out value)) {
value = new List<DateTime>();
dict.Add(key, value);
}
// value is now always a valid instance
var dict = new Dictionary<string, List<DateTime>>();
Kindness,
Dan
Maybe like:
Dictionary<String, List<DateTime>> myDict = new Dictionary<String, List<DateTime>>();