开发者

DateTime.AddDays(7) vs Calendar.AddWeeks(1)

开发者 https://www.devze.com 2023-02-13 04:42 出处:网络
Can both methods deliver different results under certain circumstances? Same question for ne开发者_如何学Gogative values...Straight from Reflector:

Can both methods deliver different results under certain circumstances? Same question for ne开发者_如何学Gogative values...


Straight from Reflector:

public DateTime AddDays(double value)
{
    return this.Add(value, 86400000);
}

public virtual DateTime AddWeeks(DateTime time, int weeks)
{
    return this.AddDays(time, weeks * 7);
}

Note, however, that AddWeeks is defined as virtual.


They always do the same thing. AddMonth and AddYears will vary but a week is always 7 days

0

精彩评论

暂无评论...
验证码 换一张
取 消