字符串无法识别时间跨度

时间:2016-01-28 09:23:11

标签: c# timespan

希望你能帮我解决这个问题。昨天我的代码工作正常,但是在我做了一些清理工作后,它停止了工作,并继续说:

String was not recognized as a valid TimeSpan

        DataTable dt = new DataTable();
        dt = database.getSchedule();
        TimeSpan AMTime;
        TimeSpan PMTime;
        TimeSpan NNTime;
        TimeSpan _timeNow =  TimeSpan.Parse(timeNow);

        foreach (DataRow row in dt.Rows)
        {
            AMTime = TimeSpan.Parse(row["AMIntake"].ToString());
            PMTime = TimeSpan.Parse(row["PMIntake"].ToString());
            NNTime = TimeSpan.Parse(row["NNIntake"].ToString());

            if (AMTime == _timeNow || PMTime == _timeNow || NNTime == _timeNow)
            {
                 MessageBox.Show("Drink Medicine");
            }
           else
            {
               /*do nothing*/
            }

0 个答案:

没有答案