如何获得一个月的最后一天?一个月、如何获得

2023-09-02 01:35:42 作者:靜候婲開雁归来

我如何能找到一个月的最后一天,在C#?

How can I find the last day of the month in C#?

例如。如果我有日期1980年3月8日,我怎么弄8月的最后一天(在本例中31)?

e.g. if I have the date 03/08/1980, how do I get the last day of month 8 (in this case 31)?

推荐答案

你得到这样的月份,它返回31年的最后一天:

The last day of the month you get like this, which returns 31:

DateTime.DaysInMonth(1980, 08);