📜  如何在 c# 代码示例中的小时范围之间进行迭代

📅  最后修改于: 2022-03-11 14:49:13.939000             🧑  作者: Mango

代码示例1
DateTime testDate = new DateTime(2011, 12, 15, 00, 00, 00, DateTimeKind.Local);
DateTime endDate = testDate.AddDays(1);

while (testDate.Date != endDate.Date)
{
    Console.WriteLine(testDate.ToString());
    testDate = testDate.AddHours(1);
}