Section 19.8: DateTime.DaysInMonth(Int32, Int32) 메소드

const int July = 7; const int Feb = 2; int daysInJuly = System.DateTime.DaysInMonth(2001, July); Console.WriteLine(daysInJuly); // 1998 년도는 윤년이 아니었기 때문에 daysInFeb 의 값은 28 이 될 것이다. int daysInFeb = System.DateTime.DaysInMonth(1998, Feb); Console.WriteLine(daysInFeb); // 1996 년도는 윤년이었기 때문에 daysInFebLeap 의 값은 29 가 될 것이다. int daysInFebLeap = System.DateTime.DaysInMonth(1996, Feb); Console.WriteLine(daysInFebLeap);

출력 결과:

31 28 29
본 문서는 C# Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.

[출처] https://books.goalkicker.com/CSharpBook/

반응형

+ Recent posts