我有一个结构,它包含一个int
值作为键,一组datetime
作为值。
我的问题是如何在C#中表示这样的结构?
我尝试过Dictionary<int, DateTime[]>
,但在添加和删除datetime
元素时无法使用字典,因为字典总是需要为每个键使用不同的数组,这在我的应用程序中编程是不切实际的。
发布于 2011-12-25 20:05:03
此数据结构将起作用:
IDictionary<int,List<DateTime>> datesById = new Dictionary<int,List<DateTime>>();
datesById.Add(1, new List<DateTime>());
datesById[1].Add(DateTime.Now);
发布于 2011-12-25 20:10:02
C#中的容器有相应的方法将自身转换为其他容器
https://stackoverflow.com/questions/8631315
复制相似问题