本文介绍了当我为getdate()添加时间时,我希望在结束时关闭一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

when i added time to getdate() , i want to stop when day closed at a end time





喜欢今天26/2/2018 20:00:00 pm我想停止27/2/2018 00:00:00 in while循环



我尝试过:



喜欢今天26/2/2018 20:00:00 pm我想停止27/2/2018 00: 00:00 in while循环



like today 26/2/2018 20:00:00 pm i want to stop 27/2/2018 00:00:00 in while loop

What I have tried:

like today 26/2/2018 20:00:00 pm i want to stop 27/2/2018 00:00:00 in while loop

推荐答案

System.DateTime dt = System.DateTime.Now;
System.TimeSpan duration = new System.TimeSpan(0, 1, 5, 0);

int day = dt.Day;
while (dt.Day == day)
{
  Console.WriteLine(dt.ToString());
  dt = dt.Add(duration);
}


这篇关于当我为getdate()添加时间时,我希望在结束时关闭一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 00:47