TA貢獻1893條經驗 獲得超10個贊
您將在該月的最后一天返回31:
DateTime.DaysInMonth(1980, 08);
TA貢獻1725條經驗 獲得超8個贊
如果要給定一個月和一年的日期,這似乎是正確的:
public static DateTime GetLastDayOfMonth(this DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, DateTime.DaysInMonth(dateTime.Year, dateTime.Month));
}
舉報
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號