gpt4 book ai didi

C# DateTime.AddMonth 下个月不存在日期

转载 作者:太空狗 更新时间:2023-10-29 22:02:24 24 4
gpt4 key购买 nike

如果我有 DateTime date = new DateTime("1/31/2010"); 并且我调用 date.AddMonth(1)。我会收到“2/28/2010”还是会因为“2/31/2010”不存在而大吃一惊?或者我会得到“3/3/2010”吗?

(而且我不在装有 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.

关于C# DateTime.AddMonth 下个月不存在日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5421293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com