用C#表示结构

ÚÒí*_*áÈí 2 c# dictionary key

我有一个结构,其中包含一个int值作为键和一组datetime作为值.

我的问题是如何在C#中表示这样的结构?

我试过Dictionary<int, DateTime[]>但是在添加和删除datetime元素时我不能使用字典,因为字典总是需要为每个键使用不同的数组,这在我的应用程序中编程是不实际的.

Ode*_*ded 5

这个数据结构将起作用:

IDictionary<int,List<DateTime>> datesById = new Dictionary<int,List<DateTime>>();

datesById.Add(1, new List<DateTime>());
datesById[1].Add(DateTime.Now);
Run Code Online (Sandbox Code Playgroud)