3 回答
TA贡献1784条经验 获得超2个赞
首先,使用有意义的名称而不是aand b,其次:使用正确的数据类型(你根本不使用b):
int dayOffset = -1;
int lowerBound = -15;
var currentDate = DateTime.Now;
if(input >= currentDate.AddDays(dayOffset) && input <= currentDate)
{ // do smoething }
使用你的名字:
var currentDate = DateTime.Now;
if(input >= currentDate.AddDays(a) && input <= currentDate)
{ // do smoething }
TA贡献1871条经验 获得超13个赞
你可以尝试这样的事情来比较Date部分Time
string a = "-1"; // These are values that are configurable based on which date is checked. Yesterday means, -1 for example.
string b = "-15"; // -15 means within last 15 days.
DateTime d = new DateTime();
DateTime e = d.AddDays(int.Parse(a));
if (DateTime.Now.Date >= d.Date && e.Date <= d.Date)
{
}
- 3 回答
- 0 关注
- 240 浏览
添加回答
举报