如题,谢谢各位!

解决方案 »

  1.   


    研究一下 算法。  15:20---22:10String 【】 arr= 函数(开始时间,结束时间);
      

  2.   


    DateTime begin = DateTime.Parse("2008-1-1 1:11:31");
    DateTime end = DateTime.Parse("2008-1-1 11:11:21");
    DateTime temp = begin;
    while (temp.CompareTo(end) <= 0)
    {
        Console.WriteLine(temp);
        temp = temp.AddHours(1);
    }
      

  3.   

    上面这个好像不能够枚举出所有的整点时刻,下面的我改写了一下
    DateTime begin = DateTime.Parse("2008-1-1 1:11:31");
    DateTime end = DateTime.Parse("2008-1-1 11:11:21");
    DateTime temp = begin;
    while (temp.CompareTo(end) <= 0)
    {
        Console.WriteLine(temp.year + "年" + temp.month + "月" + temp.day + "日" + temp.hour + "时");
        temp = temp.AddHours(1);
    }
    这样应该可以吧
      

  4.   


    DateTime start = DateTime.Parse("2008-1-1 1:1:1");
    DateTime end = DateTime.Parse("2008-1-1 11:11:11");DateTime current = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
    current = current.AddHours(1);while (current <= end)
    {
    System.Console.WriteLine(current.ToString("yyyy-MM-dd hh:mm"));
    current = current.AddHours(1);
    }
      

  5.   


    private List<DateTime> GetDateTime(DateTime startTime, DateTime endTime)
    {
        if(startTime >= endTime)
            return null;
        if(startTime.AddHour(1)>endTime)
            return null;
        List<DateTime> list = new List<DateTime>();
        DateTime tempDate = new DateTime(startTime.Year,startTime.Month,startTime.Day,startTime.Hour,0,0);
        if(tempDate == startTime)
            list.Add(tempDate);
        while(tempDate <= endTime)
        {
            tempDate=tempDate.AddHour(1);
            list.Add(tempDate);
        }
        return list;
    }