C# 获取时间区间内所有的时间以及天数
var startTime = DateTime.Parse("2023-6-25"); var endTime = DateTime.Parse("2023-6-29"); int validDay = 0; for (DateTime currentDate = startTime; currentDate <= endTime; currentDate = currentDate.AddDays(1)) { Console.WriteLine(currentDate); validDay++; } Console.WriteLine(validDay); Console.ReadKey();
本文来自博客园,作者:WantRemake,转载请注明原文链接:https://www.cnblogs.com/SmallChen/p/17505675.html