DateTime.Equality(DateTime, DateTime) 演算子

定義

DateTime の 2 つの指定したインスタンスが等しいかどうかを判断します。Determines whether two specified instances of DateTime are equal.

public:
 static bool operator ==(DateTime d1, DateTime d2);
public static bool operator == (DateTime d1, DateTime d2);
static member ( = ) : DateTime * DateTime -> bool
Public Shared Operator == (d1 As DateTime, d2 As DateTime) As Boolean

パラメーター

d1
DateTime

比較する最初のオブジェクト。The first object to compare.

d2
DateTime

比較する 2 番目のオブジェクト。The second object to compare.

戻り値

trued1 が同じ日付と時刻を表す場合は d2。それ以外の場合は falsetrue if d1 and d2 represent the same date and time; otherwise, false.

等値演算子の例を次に示します。The following example demonstrates the equality operator.

System::DateTime april19( 2001, 4, 19 );
System::DateTime otherDate( 1991, 6, 5 );

// areEqual gets false.
bool areEqual = april19 == otherDate;

otherDate = DateTime( 2001, 4, 19 );
// areEqual gets true.
areEqual = april19 == otherDate;
System.DateTime april19 = new DateTime(2001, 4, 19);
System.DateTime otherDate = new DateTime(1991, 6, 5);

// areEqual gets false.
bool areEqual = april19 == otherDate;
    
otherDate = new DateTime(2001, 4, 19);
// areEqual gets true.
areEqual = april19 == otherDate;
Dim april19 As New DateTime(2001, 4, 19)
Dim otherDate As New DateTime(1991, 6, 5)

Dim areEqual As Boolean
' areEqual gets false.
areEqual = DateTime.op_Equality(april19, otherDate)

otherDate = New DateTime(2001, 4, 19)
' areEqual gets true.
areEqual = System.DateTime.op_Equality(april19, otherDate)

注釈

Equality 演算子は、タイマー刻みの数を比較することによって、2つの DateTime 値が等しいかどうかを判断します。The Equality operator determines whether two DateTime values are equal by comparing their number of ticks. DateTime オブジェクトを比較する前に、オブジェクトが同じタイムゾーンの時刻を表していることを確認してください。Before comparing DateTime objects, make sure that the objects represent times in the same time zone. これを行うには、Kind プロパティの値を比較します。You can do this by comparing the values of their Kind property.

この演算子の同等のメソッドは DateTime.Equals(Object)The equivalent method for this operator is DateTime.Equals(Object)

適用対象

こちらもご覧ください