DateTimeOffset.EqualsExact(DateTimeOffset) 메서드

정의

현재 DateTimeOffset 개체가 지정된 DateTimeOffset 개체와 같은 시간을 나타내고 오프셋이 같은지 확인합니다.

public:
 bool EqualsExact(DateTimeOffset other);
public bool EqualsExact (DateTimeOffset other);
member this.EqualsExact : DateTimeOffset -> bool
Public Function EqualsExact (other As DateTimeOffset) As Boolean

매개 변수

other
DateTimeOffset

현재 DateTimeOffset 개체와 비교할 개체입니다.

반환

Boolean

현재 DateTimeOffset 개체와 other의 날짜 및 시간 값이 같고 Offset 값이 같으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드를 사용하여 유사한 DateTimeOffset 개체를 EqualsExact 비교하는 방법을 보여 줍니다.

DateTimeOffset instanceTime = new DateTimeOffset(2007, 10, 31, 0, 0, 0,
                              DateTimeOffset.Now.Offset);

DateTimeOffset otherTime = instanceTime;
Console.WriteLine("{0} = {1}: {2}",
                  instanceTime, otherTime,
                  instanceTime.EqualsExact(otherTime));

otherTime = new DateTimeOffset(instanceTime.DateTime,
            TimeSpan.FromHours(instanceTime.Offset.Hours + 1));
Console.WriteLine("{0} = {1}: {2}",
                  instanceTime, otherTime,
                  instanceTime.EqualsExact(otherTime));

otherTime = new DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours(1),
                TimeSpan.FromHours(instanceTime.Offset.Hours + 1));
Console.WriteLine("{0} = {1}: {2}",
                  instanceTime, otherTime,
                  instanceTime.EqualsExact(otherTime));
// The example produces the following output:
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False
let instanceTime = DateTimeOffset(2007, 10, 31, 0, 0, 0, DateTimeOffset.Now.Offset)

let otherTime = instanceTime
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"

let otherTime = DateTimeOffset(instanceTime.DateTime, TimeSpan.FromHours(instanceTime.Offset.Hours + 1 |> float))
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"

let otherTime = DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours 1, TimeSpan.FromHours(instanceTime.Offset.Hours + 1 |> float))
printfn $"{instanceTime} = {otherTime}: {instanceTime.EqualsExact otherTime}"

// The example produces the following output:
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
//       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False
Dim instanceTime As New DateTimeOffset(#10/31/2007 12:00AM#, _
                                       DateTimeOffset.Now.Offset)

Dim otherTime As DateTimeOffset = instanceTime
Console.WriteLine("{0} = {1}: {2}", _
                  instanceTime, otherTime, _
                  instanceTime.EqualsExact(otherTime))
                  
otherTime = New DateTimeOffset(instanceTime.DateTime, _
                               TimeSpan.FromHours(instanceTime.Offset.Hours + 1))
Console.WriteLine("{0} = {1}: {2}", _
                  instanceTime, otherTime, _
                  instanceTime.EqualsExact(otherTime))
                  
otherTime = New DateTimeOffset(instanceTime.DateTime + TimeSpan.FromHours(1), _
                                TimeSpan.FromHours(instanceTime.Offset.Hours + 1))
Console.WriteLine("{0} = {1}: {2}", _
                  instanceTime, otherTime, _
                  instanceTime.EqualsExact(otherTime))
' The example produces the following output:
'       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -07:00: True
'       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 12:00:00 AM -06:00: False
'       10/31/2007 12:00:00 AM -07:00 = 10/31/2007 1:00:00 AM -06:00: False

설명

여러 표준 시간대가 단일 오프셋을 공유하기 때문에 반환 값은 true 현재와 other 개체가 동일한 표준 시간대의 시간을 나타내는 것을 보장하지 않습니다.

메서드와 EqualsExact 달리 메서드의 오버로드는 두 DateTimeOffset 값이 Equals 단일 시점을 나타내는지 여부만 결정합니다. 두 값이 동일한 오프셋뿐만 아니라 날짜와 시간이 같음을 나타내지 않습니다.

적용 대상

추가 정보