如题,谢谢各位!
解决方案 »
- CODESOFT6 如何在程序中动态设置Text显示位置
- C#数据类型和C语言有什么不同?
- 关于FolderBrowserDialog的问题
- 哪位高人可以帮我解决这个问题啊:C#中如何计算并更改FOR循环打印的非静态的字符串?
- 关于主从表的问题,高手、大虾进来看看!!!!
- 关于CSDN离线浏览器
- main方法中为什么可以包含非静态数据
- winform 下HttpWebRequest 和xmlhttp去下载网页.哪个好?
- 如何用SQLParameter,获得存储过程返回的值
- 画图 刷子的定义
- 如何设置Web Service的连接超时时间?!!!!!!!!!!!!!!
- 逼我再发一新帖吗这不是! 求助:问题描述里边有详细说明!
研究一下 算法。 15:20---22:10String 【】 arr= 函数(开始时间,结束时间);
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);
}
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);
}
这样应该可以吧
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);
}
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;
}