且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从字符串获取值到datetime.today.addhours

更新时间:2023-11-07 09:21:46

AddHours方法获得double( ^ ])作为参数,因此您必须将字符串转换为双精度值(尝试使用 ^ ]方法).
AddHours method gets a double (MSDN[^]) as argument, hence you have to convert your string to a double value (try the Double.Parse[^] method).




从您的解释中,我可以得出这个答案.让我知道这是否适合.

Hi,

From your explanation, I could come up with this answer. Let me know if this suits.

DateTime startTime =Convert.ToDateTime(dttimeslot.Rows[0]["day_start_time"].ToString());
DateTime endTime=Convert.ToDateTime(dttimeslot.Rows[0]["day_end_time"].ToString());

while (startTime < endTime)
{
    startTime = startTime.AddMinutes(inc);
    //Your logic here
}



这有帮助吗?



Does this help?