Share via


DateTime 等値演算子

DateTime の 2 つの指定したインスタンスが等しいかどうかを判断します。

returnValue = DateTime.op_Equality(d1, d2)
[C#]
public static bool operator ==(DateTimed1,DateTimed2);
[C++]
public: static bool op_Equality(DateTimed1,DateTimed2);
[JScript]
returnValue = d1 == d2;

[Visual Basic] Visual Basic では、この型で定義されている演算子を使用することができます。ただし、独自に定義することはできません。Equals メソッドを DateTime 等値演算子の代わりに使用することができます。

[JScript] JScript では、この型で定義されている演算子を使用することができます。ただし、独自に定義することはできません。

引数 [Visual Basic, JScript]

パラメータ [C#, C++]

戻り値

d1d2 が同じ日付と時刻を表す場合は true 。それ以外の場合は false

使用例

[Visual Basic, C#, C++] 等値演算子を次のサンプルで示します。

 
Dim april19 As New DateTime(2001, 4, 19)
Dim otherDate As New DateTime(1991, 6, 5)

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

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

[C#] 
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;

[C++] 
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;

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

DateTime 構造体 | DateTime メンバ | System 名前空間 | Boolean