一个程序的问题
DateTime kqlssj1;
if (rowkqls.Issj1Null())
{
rowkqls.ssbqk = "未考勤 ";
}
else
{
//DateTime
kqlssj1 = rowkqls.sj1;
}
if (ss && rowkqls.Issj1Null())
{
TimeSpan t1 = kqlssj1.TimeOfDay.Subtract(Sjsj1.TimeOfDay);
编译后出错,说
TimeSpan t1 = kqlssj1.TimeOfDay.Subtract(Sjsj1.TimeOfDay);
中的kqlssj1未赋值,这个是怎么回事啊
------解决方案--------------------你在定义的时候初始化一下
------解决方案--------------------将DateTime kqlssj1;改成
DateTime kqlssj1 = DateTime.Now;