DaysInMonth를 사용하여 한 달의 일 수를 표시합니다.
DaysInMonth() 메서드의 매개변수로 연도와 월을 추가합니다. -
DateTime.DaysInMonth(2018, 8);
다음은 예입니다 -
예시
using System;
using System.Collections.Generic;
using System.Linq;
public class Demo {
public static void Main() {
Console.WriteLine("Today = {0}", DateTime.Today);
int num_days = DateTime.DaysInMonth(2018, 8);
Console.WriteLine("Days in August: "+num_days);
}
} 출력
Today = 9/4/2018 12:00:00 AM Days in August: 31