If I have DateTime date = new DateTime("1/31/2010");
and I call date.AddMonth(1)
. Will I get "2/28/2010" or will it freak out because "2/31/2010" doesn't exist? Or will I get "3/3/2010"?
(Also I'm not near a computer with Visual Studio)
If the resulting day is not a valid day in the resulting month, the last valid day of the resulting month is used. For example, March 31st + 1 month = April 30th.
你会得到下个月的结束日,所以2月28日。
它将添加正确的DateTime月份并返回2010年2月28日
它不会破坏,它会给你2/28/2010
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.