2009-09-04 24 views

回答

10
Dictionary<string, List<DateTime>> dict = new Dictionary<string, List<DateTime>>(); 

需要注意的是,添加新項目時,你需要分配一個新的列表值:

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 
+1

+1:我2秒已晚...; O) – 2009-09-04 13:16:36

+0

OOOOoooops .....我是喝醉了嗎? ....可能我試過這個,但可能不是這個:)。謝謝 – 2009-09-04 13:22:48

1
Dictionary<string, List<DateTime>> 
+0

您可能必須更具體一些。 – 2009-09-04 13:17:49

2
var dict = new Dictionary<string, List<DateTime>>(); 

善良,

1
Dictionary<string, List<DateTime>> oDictionary; 
1

也許就像:

Dictionary<String, List<DateTime>> myDict = new Dictionary<String, List<DateTime>>(); 
相關問題