你知道我怎么做吗?
public override IDictionary<int, DateTime> GetList()
{
var AdList = new Dictionary<int, DateTime>();
AdList = client.GetAdList(loginTicket); //it returns int array.
// I've also tried AdList =client.GetAdList(loginTicket).ToDictionary<int, DateTime>(); it doesn't work..
return AdList;
}
答案 0 :(得分:0)
好吧,没有关于你如何获取日期的信息,或者你从哪里得到它们,但我可以建议一些代码:
public static IDictionary<int, DateTime> GetList()
{
var AdList = new Dictionary<int, DateTime>();
var intArr = GetAdList(); //get your int[] array or List<int>
//if method GetAdList() returns List<int> use this line
intArr.ForEach(a => AdList.Add(a, DateTime.Now));
//otherwise if method returns int[] array use this line
Array.ForEach(intArr, a => AdList.Add(a, DateTime.Now)); //populate dictionary with array elements as keys and DateTime.Now as values
return AdList;
}