C#DateTimeDateTime.DaysInMonth
DateTime.TryParse

DateTime.DaysInMonthDateTime

DateTime.IsLeapYear

Returns the number of days in the specified month and year.

문법

DateTime.DaysInMonth(year, month)

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

Console
WriteLine
DaysInMonth
leap
Console.WriteLine(DateTime.DaysInMonth(2024, 2));   // 29 (leap year)
Console.WriteLine(DateTime.DaysInMonth(2023, 2));   // 28