我的代码是这样的,但我需要验证RemainingDay
是否超过10,然后它不会显示剩余天数的消息框
if (Convert.ToDateTime(dr[0]) == DateTime.Today)
{
MessageBox.Show("Your trail period is expired. Please purchase this Software.", "SMS");
Application.Exit();
}
else
{
newDate = Convert.ToDateTime(dr[0]);
RemainingDay = newDate.Subtract(TodayDate);
MessageBox.Show("You have " + RemainingDay.Days + " days Left.", "SMS");
this.Hide();
frmMainMenu frm = new frmMainMenu();
frm.Show();
frm.lblUser.Text = txtUserName.Text;
}
我尝试了以下代码:
if (Convert.ToDateTime(dr[0]) == DateTime.Today)
{
MessageBox.Show("Your trail period is expired. Please purchase this Software.", "SMS");
Application.Exit();
}
else
{
newDate = Convert.ToDateTime(dr[0]);
RemainingDay = newDate.Subtract(TodayDate);
if (RemainingDay <= 10)
{
MessageBox.Show("You have " + RemainingDay.Days + " days Left.", "SMS");
this.Hide();
}
else
{
this.Hide();
frmMainMenu frm = new frmMainMenu();
frm.Show();
frm.lblUser.Text = txtUserName.Text;
}
}
上面的代码给了我这个错误:
运营商&#39;&gt; =&#39;不能应用于类型&#39; System.DateTime?&#39;的操作数?和&#39; int&#39;
请帮帮我。