项目中的计时器控制 [英] timer control in project

查看:54
本文介绍了项目中的计时器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

objTimeSpent = DateTime.Now.Subtract(ViewState("StartTime"))

推荐答案

如果没有继续显示错误消息,我只能建议您在转换之前将ViewState("StartTime")转换为DateTime您可以使用它.
Without the explicit error messge to go on, I can only suggest that you need to cast ViewState("StartTime") to a DateTime before you use it.


我从您的问题中了解到,您在视图状态下有一些日期时间值,并且想要从当前时间中减去它.
What I understood from your question is, you have some date time value in view state and you want to subtract it from current time.
var timespan = DateTime.Now.Subtract((DateTime)ViewState["DateTime"])



您必须检查ViewState是否为空或有效的日期时间值.否则,您将获得例外.
要了解有关DateTime的更多信息,请在此处检查 [



You must need to check the ViewState for null or valid date time value. Else you will get exception.
To know more about the DateTime check here[^]


这篇关于项目中的计时器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆