DateTime.Equals DateTime.Equals DateTime.Equals DateTime.Equals Method

정의

DateTime 개체가 같은지 여부 또는 DateTime 인스턴스와 또 다른 개체 또는 DateTime의 값이 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether two DateTime objects, or a DateTime instance and another object or DateTime, have the same value.

오버로드

Equals(DateTime, DateTime) Equals(DateTime, DateTime) Equals(DateTime, DateTime) Equals(DateTime, DateTime)

DateTime 인스턴스의 날짜 및 시간 값이 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether two DateTime instances have the same date and time value.

Equals(DateTime) Equals(DateTime) Equals(DateTime) Equals(DateTime)

이 인스턴스의 값이 지정된 DateTime 인스턴스의 값과 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether the value of this instance is equal to the value of the specified DateTime instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether this instance is equal to a specified object.

Equals(DateTime, DateTime) Equals(DateTime, DateTime) Equals(DateTime, DateTime) Equals(DateTime, DateTime)

DateTime 인스턴스의 날짜 및 시간 값이 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether two DateTime instances have the same date and time value.

public:
 static bool Equals(DateTime t1, DateTime t2);
public static bool Equals (DateTime t1, DateTime t2);
static member Equals : DateTime * DateTime -> bool
Public Shared Function Equals (t1 As DateTime, t2 As DateTime) As Boolean

매개 변수

t1
DateTime DateTime DateTime DateTime

비교할 첫 번째 개체입니다.The first object to compare.

t2
DateTime DateTime DateTime DateTime

비교할 두 번째 개체입니다.The second object to compare.

반환

두 값이 같으면 true이고, 그렇지 않으면 false입니다.true if the two values are equal; otherwise, false.

예제

다음 예제는 Equals 메서드.The following example demonstrates the Equals method.

System::DateTime today1 = System::DateTime(
   System::DateTime::Today.Ticks );
System::DateTime today2 = System::DateTime(
   System::DateTime::Today.Ticks );
System::DateTime tomorrow = System::DateTime(
   System::DateTime::Today.AddDays( 1 ).Ticks );

// todayEqualsToday gets true.
bool todayEqualsToday = System::DateTime::Equals( today1, today2 );

// todayEqualsTomorrow gets false.
bool todayEqualsTomorrow = System::DateTime::Equals( today1, tomorrow );
System.DateTime today1 = 
        new System.DateTime(System.DateTime.Today.Ticks);
System.DateTime today2 = 
        new System.DateTime(System.DateTime.Today.Ticks);
System.DateTime tomorrow = 
        new System.DateTime(
                    System.DateTime.Today.AddDays(1).Ticks);

// todayEqualsToday gets true.
bool todayEqualsToday = System.DateTime.Equals(today1, today2);

// todayEqualsTomorrow gets false.
bool todayEqualsTomorrow = System.DateTime.Equals(today1, tomorrow);
Dim today1 As New System.DateTime(System.DateTime.Today.Ticks)
Dim today2 As New System.DateTime(System.DateTime.Today.Ticks)
Dim tomorrow As New System.DateTime( _
                        System.DateTime.Today.AddDays(1).Ticks)

' todayEqualsToday gets true.
Dim todayEqualsToday As Boolean = System.DateTime.Equals(today1, today2)

' todayEqualsTomorrow gets false.
Dim todayEqualsTomorrow As Boolean = System.DateTime.Equals(today1, tomorrow)

설명

t1t2 같은지 경우 해당 Ticks 속성 값이 동일 합니다.t1 and t2 are equal if their Ticks property values are equal. 해당 Kind 속성 값 같음 테스트에서 고려 되지 않습니다.Their Kind property values are not considered in the test for equality.

추가 정보

Equals(DateTime) Equals(DateTime) Equals(DateTime) Equals(DateTime)

이 인스턴스의 값이 지정된 DateTime 인스턴스의 값과 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether the value of this instance is equal to the value of the specified DateTime instance.

public:
 virtual bool Equals(DateTime value);
public bool Equals (DateTime value);
override this.Equals : DateTime -> bool
Public Function Equals (value As DateTime) As Boolean

매개 변수

value
DateTime DateTime DateTime DateTime

이 인스턴스와 비교할 개체입니다.The object to compare to this instance.

반환

true 매개 변수가 이 인스턴스의 값과 같으면 value이고, 그렇지 않으면 false입니다.true if the value parameter equals the value of this instance; otherwise, false.

구현

예제

다음 예제는 Equals 메서드.The following example demonstrates the Equals method.

using System;

public class Application
{
    public static void Main()
    {
        // Create some DateTime objects.
        DateTime one = DateTime.UtcNow;

        DateTime two = DateTime.Now;

        DateTime three = one;

        // Compare the DateTime objects and display the results.
        bool result = one.Equals(two);

        Console.WriteLine("The result of comparing DateTime object one and two is: {0}.", result);

        result = one.Equals(three);

        Console.WriteLine("The result of comparing DateTime object one and three is: {0}.", result);
    }
}

// This code example displays the following:
//
// The result of comparing DateTime object one and two is: False.
// The result of comparing DateTime object one and three is: True.
Module Application

    Sub Main()
        ' Create some DateTime objects.
        Dim one As DateTime = DateTime.UtcNow

        Dim two As DateTime = DateTime.Now

        Dim three As DateTime = one

        ' Compare the DateTime objects and display the results.
        Dim result As Boolean = one.Equals(two)

        Console.WriteLine("The result of comparing DateTime object one and two is: {0}.", result)

        result = one.Equals(three)

        Console.WriteLine("The result of comparing DateTime object one and three is: {0}.", result)

    End Sub
End Module

' This code example displays the following:
'
' The result of comparing DateTime object one and two is: False.
' The result of comparing DateTime object one and three is: True.

설명

현재 인스턴스 및 value 같은지 경우 해당 Ticks 속성 값이 동일 합니다.The current instance and value are equal if their Ticks property values are equal. 해당 Kind 속성 값 같음 테스트에서 고려 되지 않습니다.Their Kind property values are not considered in the test for equality.

이 메서드를 구현 하는 System.IEquatable<T> 인터페이스 및 수행 보다 조금 더 나은 합니다 Equals 메서드 때문에 value 매개 변수를 개체로 변환할 필요가 없습니다.This method implements the System.IEquatable<T> interface, and performs slightly better than the Equals method because the value parameter does not have to be converted to an object.

추가 정보

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.Returns a value indicating whether this instance is equal to a specified object.

public:
 override bool Equals(System::Object ^ value);
public override bool Equals (object value);
override this.Equals : obj -> bool
Public Overrides Function Equals (value As Object) As Boolean

매개 변수

value
Object Object Object Object

이 인스턴스와 비교할 개체입니다.The object to compare to this instance.

반환

truevalue의 인스턴스이고 이 인스턴스의 값과 같으면 DateTime이고, 그렇지 않으면 false입니다.true if value is an instance of DateTime and equals the value of this instance; otherwise, false.

예제

다음 예제는 Equals 메서드.The following example demonstrates the Equals method.

using System;

public class Application
{
    public static void Main()
    {
        // Create some DateTime objects.
        DateTime one = DateTime.UtcNow;

        DateTime two = DateTime.Now;

        DateTime three = one;

        // Compare the DateTime objects and display the results.
        bool result = one.Equals(two);

        Console.WriteLine("The result of comparing DateTime object one and two is: {0}.", result);

        result = one.Equals(three);

        Console.WriteLine("The result of comparing DateTime object one and three is: {0}.", result);
    }
}

// This code example displays the following:
//
// The result of comparing DateTime object one and two is: False.
// The result of comparing DateTime object one and three is: True.
Module Application

    Sub Main()
        ' Create some DateTime objects.
        Dim one As DateTime = DateTime.UtcNow

        Dim two As DateTime = DateTime.Now

        Dim three As DateTime = one

        ' Compare the DateTime objects and display the results.
        Dim result As Boolean = one.Equals(two)

        Console.WriteLine("The result of comparing DateTime object one and two is: {0}.", result)

        result = one.Equals(three)

        Console.WriteLine("The result of comparing DateTime object one and three is: {0}.", result)

    End Sub
End Module

' This code example displays the following:
'
' The result of comparing DateTime object one and two is: False.
' The result of comparing DateTime object one and three is: True.

설명

현재 인스턴스 및 value 같은지 경우 해당 Ticks 속성 값이 동일 합니다.The current instance and value are equal if their Ticks property values are equal. 해당 Kind 속성 값 같음 테스트에서 고려 되지 않습니다.Their Kind property values are not considered in the test for equality.

추가 정보

적용 대상