TimeSpan usedate=System.DateTime.Now.ToShortDateString()-Convert.ToDateTime(tUseDate.Value).ToShortDateString();
Response.Write(usedate.TotalHours);tUseDate.Value为Input所输入的时间
提示错误:
c:\inetpub\wwwroot\zwasset\asset\deviceonline.aspx.cs(68): 运算符“-”无法应用于“string”和“string”类型的操作数
Response.Write(usedate.TotalHours);tUseDate.Value为Input所输入的时间
提示错误:
c:\inetpub\wwwroot\zwasset\asset\deviceonline.aspx.cs(68): 运算符“-”无法应用于“string”和“string”类型的操作数
c:\inetpub\wwwroot\zwasset\asset\deviceonline.aspx.cs(68): 与“string.Substring(int)”最匹配的重载方法具有一些无效参数c:\inetpub\wwwroot\zwasset\asset\deviceonline.aspx.cs(68): 参数“1” : 无法从“string”转换为“int”
TimeSpan usedate=Convert.ToString(System.DateTime.Now.ToShortDateString().Substring(Convert.ToInt32(Convert.ToDateTime(tUseDate.Value).ToShortDateString())));
c:\inetpub\wwwroot\zwasset\asset\deviceonline.aspx.cs(68): 无法将类型“string”隐式转换为“System.TimeSpan”
你可以查查这个函数的返回值类型 是string 当然会出错了TimeSpan usedate=Convert.ToDateTime(System.DateTime.Now.ToShortDateString())-Convert.ToDateTime(Convert.ToDateTime(tUseDate.Value).ToShortDateString());