System Namespace DateTime Structure
Returns a value indicating whether two instances of DateTime are equal.
[ VB ]
<Serializable>
Overloads Public Shared Function Equals ( _
ByVal t1 As DateTime, _
ByVal t2 As DateTime _
} As Boolean
[ C# ]
[ Serializable ]
public static bool Equals (
DateTime t1,
DateTime t2
};
[ C++ ]
[ Serializable ]
public: static bool Equals (
DateTime t1,
DateTime t2
};
[ JScript ]
public Serializable
static function Equals (
t1 : DateTime,
t2 : DateTime
} : Boolean;
- t1
- The first DateTime.
- t2
- The second DateTime.
true if the two DateTime values are equal; otherwise, false.
The below code snippet demonstrates using the Equals method.
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 ) |
|
C# |
VB |
DateTime Members DateTime.Equals Overload List Boolean Compare CompareTo