0

Do you have any idea how I can do it?

 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;
     } 
4

1 回答 1

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;
}
于 2013-07-22T14:36:17.480 回答