DateTime.Add(TimeSpan) 메서드
정의
public:
DateTime Add(TimeSpan value);
public DateTime Add (TimeSpan value);
member this.Add : TimeSpan -> DateTime
Public Function Add (value As TimeSpan) As DateTime
매개 변수
- value
- TimeSpan
양수 또는 음수의 시간 간격입니다.A positive or negative time interval.
반환
이 인스턴스가 나타내는 날짜 및 시간과 value
가 나타내는 시간 간격의 합이 값인 개체입니다.An object whose value is the sum of the date and time represented by this instance and the time interval represented by value
.
예외
결과는 DateTime이 MinValue보다 작거나 MaxValue보다 큽니다.The resulting DateTime is less than MinValue or greater than MaxValue.
예제
다음 예제는 Add 메서드.The following example demonstrates the Add method. 이 순간부터 36 일 (864 시간)는 요일을 계산 합니다.It calculates the day of the week that is 36 days (864 hours) from this moment.
// Calculate what day of the week is 36 days from this instant.
System::DateTime today = System::DateTime::Now;
System::TimeSpan duration( 36, 0, 0, 0 );
System::DateTime answer = today.Add( duration );
System::Console::WriteLine( " {0:dddd}", answer );
// Calculate what day of the week is 36 days from this instant.
System.DateTime today = System.DateTime.Now;
System.TimeSpan duration = new System.TimeSpan(36, 0, 0, 0);
System.DateTime answer = today.Add(duration);
System.Console.WriteLine("{0:dddd}", answer);
' Calculate what day of the week is 36 days from this instant.
Dim today As System.DateTime
Dim duration As System.TimeSpan
Dim answer As System.DateTime
today = System.DateTime.Now
duration = New System.TimeSpan(36, 0, 0, 0)
answer = today.Add(duration)
System.Console.WriteLine("{0:dddd}", answer)
설명
사용할 수는 Add 단일 작업에서 여러 종류의 시간 간격 (일, 시, 분, 초 또는 밀리초)을 추가 하는 방법입니다.You can use the Add method to add more than one kind of time interval (days, hours, minutes, seconds, or milliseconds) in a single operation. 이 메서드의 동작은 더하기 연산자는 동일 합니다.This method's behavior is identical to that of the addition operator. DateTime 구조에는 특수 한 더하기 메서드도 지원 (같은 AddDays, AddHours, 및 AddMinutes) 각 시간 간격에 대 한 합니다.The DateTime structure also supports specialized addition methods (such as AddDays, AddHours, and AddMinutes) for each time interval.
Add 메서드 윤년 계정 및 날짜를 계산 하는 월의 일 수를 고려 합니다.The Add method takes into account leap years and the number of days in a month when performing date arithmetic.
이 메서드는이 값을 변경 하지 않습니다 DateTime합니다.This method does not change the value of this DateTime. 대신에 새 반환 DateTime 값인이 연산의 결과입니다.Instead, it returns a new DateTime whose value is the result of this operation. 합니다 Kind 새 속성 DateTime 인스턴스가 현재 인스턴스의 것과 동일 합니다.The Kind property of the new DateTime instance is the same as that of the current instance.