Section 19.3: DateTime.AddHours(Double) 메소드
double[] hours = {
.08333,
.16667,
.25,
.33333,
.5,
.66667,
1,
2,
29,
30,
31,
90,
365
};
DateTime dateValue = new DateTime(2009, 3, 1, 12, 0, 0);
foreach(double hour in hours)
Console.WriteLine("{0} + {1} hour(s) = {2}", dateValue, hour, dateValue.AddHours(hour));
출력 결과 :
3/1/2009 12:00:00 PM + 0.08333 hour(s) = 3/1/2009 12:04:59 PM
3/1/2009 12:00:00 PM + 0.16667 hour(s) = 3/1/2009 12:10:00 PM
3/1/2009 12:00:00 PM + 0.25 hour(s) = 3/1/2009 12:15:00 PM
3/1/2009 12:00:00 PM + 0.33333 hour(s) = 3/1/2009 12:19:59 PM
3/1/2009 12:00:00 PM + 0.5 hour(s) = 3/1/2009 12:30:00 PM
3/1/2009 12:00:00 PM + 0.66667 hour(s) = 3/1/2009 12:40:00 PM
3/1/2009 12:00:00 PM + 1 hour(s) = 3/1/2009 1:00:00 PM
3/1/2009 12:00:00 PM + 2 hour(s) = 3/1/2009 2:00:00 PM
3/1/2009 12:00:00 PM + 29 hour(s) = 3/2/2009 5:00:00 PM
3/1/2009 12:00:00 PM + 30 hour(s) = 3/2/2009 6:00:00 PM
3/1/2009 12:00:00 PM + 31 hour(s) = 3/2/2009 7:00:00 PM
3/1/2009 12:00:00 PM + 90 hour(s) = 3/5/2009 6:00:00 AM
3/1/2009 12:00:00 PM + 365 hour(s) = 3/16/2009 5:00:00 PM
본 문서는 C# Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.
[출처] https://books.goalkicker.com/CSharpBook/
'번역 > C# Notes for Professionals' 카테고리의 다른 글
19.5: DateTime.TryParse(String, DateTime) 메소드 (0) | 2021.03.17 |
---|---|
19.4: DateTime.Parse(String) 메소드 (0) | 2021.03.17 |
19.2: DateTime.AddDays(Double) 메소드 (0) | 2021.03.17 |
19.1: 날짜/시간 (DateTime) 서식 지정하기 (0) | 2021.03.16 |
18.2: 정규 표현식 패턴 다중 매칭 (0) | 2021.03.12 |