DateTime.Equality(DateTime, DateTime) DateTime.Equality(DateTime, DateTime) DateTime.Equality(DateTime, DateTime) DateTime.Equality(DateTime, DateTime) Operator

Definition

Bestimmt, ob zwei angegebene Instanzen von DateTime gleich sind.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

Parameter

d1
DateTime DateTime DateTime DateTime

Das erste zu vergleichende Objekt.The first object to compare.

d2
DateTime DateTime DateTime DateTime

Das zweite zu vergleichende Objekt.The second object to compare.

Gibt zurück

true, wenn d1 und d2 dasselbe Datum und dieselbe Uhrzeit darstellen, andernfalls false.true if d1 and d2 represent the same date and time; otherwise, false.

Beispiele

Im folgenden Beispiel wird der Gleichheits Operator veranschaulicht.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)

Hinweise

Der Equality -Operator bestimmt, DateTime ob zwei Werte gleich sind, indem er die Anzahl der Ticks vergleicht.The Equality operator determines whether two DateTime values are equal by comparing their number of ticks. Stellen Sie DateTime vor dem Vergleichen von Objekten sicher, dass die-Objekte Zeiten in derselben Zeitzone darstellen.Before comparing DateTime objects, make sure that the objects represent times in the same time zone. Hierzu können Sie die Werte ihrer Kind-Eigenschaft vergleichen.You can do this by comparing the values of their Kind property.

Die äquivalente Methode für diesen Operator ist.DateTime.Equals(Object)The equivalent method for this operator is DateTime.Equals(Object)

Gilt für:

Siehe auch