Freigeben über


DateTime.op_Equality-Methode

Bestimmt, ob zwei angegebene Instanzen von DateTime gleich sind.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Operator = ( _
    d1 As DateTime, _
    d2 As DateTime _
) As Boolean
'Usage
Dim d1 As DateTime
Dim d2 As DateTime
Dim returnValue As Boolean

returnValue = (d1 = d2)
public static bool operator == (
    DateTime d1,
    DateTime d2
)
public:
static bool operator == (
    DateTime d1, 
    DateTime d2
)
J# unterstützt keine überladenen Operatoren.
JScript unterstützt die Verwendung von überladenen Operatoren, aber nicht die Deklaration von neuen überladenen Operatoren.

Parameter

  • d2
    Eine DateTime.

Rückgabewert

true, wenn d1 und d2 dasselbe Datum und dieselbe Uhrzeit darstellen, andernfalls false.

Beispiel

Im folgenden Beispiel wird der Gleichheitsoperator veranschaulicht.

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)
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;
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.
boolean areEqual = april19 == otherDate;
otherDate = new DateTime(2001, 4, 19);
// areEqual gets true.
areEqual = april19 == otherDate;

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

DateTime-Struktur
DateTime-Member
System-Namespace
Boolean-Struktur