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();
标签:C#,天数,DateTime,Parse,时间,startTime,2023,var From: https://www.cnblogs.com/SmallChen/p/17505675.html