In C#, DateTime.Equals returns true when two values have the same number of ticks. It does not look at the Kind flag.
There are three forms: a.Equals(b) for a DateTime, a.Equals(obj) for any object, and the static DateTime.Equals(a, b). The == operator gives the same answer as the first form.
Equals comes in instance form (dt.Equals(...)) and static form (DateTime.Equals(...)). DateTime is an immutable struct, so each call gives you a result and leaves the original alone.
Syntax
Use the instance method or the static method.
C#
DateTime a = new DateTime(2026, 11, 18, 10, 0, 0);
DateTime b = new DateTime(2026, 11, 18, 10, 0, 0);
bool r1 = a.Equals(b); // true
bool r2 = DateTime.Equals(a, b); // true
bool r3 = a.Equals((object)"text"); // false
Call
What it does
a.Equals(b)
True when both have the same ticks.
DateTime.Equals(a, b)
Static form with two DateTime arguments.
a.Equals(obj)
False when obj is null or not a DateTime.
Equality needs the whole value to match, including seconds and fractions. To ignore the time, compare the Date property of each value.
Library declarations
C#
public bool Equals(DateTime value);
public override bool Equals(object? value);
public static bool Equals(DateTime t1, DateTime t2);
Parameters
Parameter
Description
value
The date or object to compare with this instance (instance overloads).
t1, t2
Two DateTime values to compare (static overload).
Return Value
Return Value
Description
bool
true if both values have the same ticks; otherwise false.
C# Examples
Example 1 — Equal and Not Equal
Compare two identical values, then a value one second later.
C#
using System;
class Program {
static void Main() {
DateTime a = new DateTime(2026, 11, 18, 10, 0, 0);
DateTime b = new DateTime(2026, 11, 18, 10, 0, 0);
DateTime c = a.AddSeconds(1);
Console.WriteLine(a.Equals(b));
Console.WriteLine(a.Equals(c));
Console.WriteLine(a == b);
}
}
Output
True
False
True
How It Works
Two copies.a and b are built from the same numbers, so the ticks match.
One second apart.c is a second later, so it is a different value.
Exact match only. Even a one-second gap makes Equals return False.
Operator.a == b uses the same rule, so it prints True.
Example 2 — Static and Object Overloads
Use DateTime.Equals, then ask a date if it equals a string and null.
C#
using System;
class Program {
static void Main() {
DateTime a = new DateTime(2026, 11, 18);
DateTime b = new DateTime(2026, 11, 18);
Console.WriteLine(DateTime.Equals(a, b));
Console.WriteLine(a.Equals((object)"2026-11-18"));
Console.WriteLine(a.Equals(null));
}
}
Output
True
False
False
How It Works
Static call.DateTime.Equals(a, b) has no instance on the left, so it needs both values.
String is not a date. Text with the same look is still a different type, so the answer is False.
Null. A DateTime is never equal to null, so the last line is False.
No exception. The object overload quietly returns false for wrong types.
Example 3 — Kind Ignored, Date Property
Compare Utc with Local, then compare a time to midnight.
C#
using System;
class Program {
static void Main() {
DateTime utc = new DateTime(2026, 11, 18, 10, 0, 0, DateTimeKind.Utc);
DateTime local = new DateTime(2026, 11, 18, 10, 0, 0, DateTimeKind.Local);
DateTime noon = new DateTime(2026, 11, 18, 12, 0, 0);
Console.WriteLine(utc.Equals(local));
Console.WriteLine(noon.Equals(new DateTime(2026, 11, 18)));
Console.WriteLine(noon.Date.Equals(new DateTime(2026, 11, 18)));
}
}
Output
True
False
True
How It Works
Different Kind. One value is Utc and the other Local, but both have the same ticks.
Equal anyway.Equals ignores Kind, so the first line is True.
Noon vs midnight. The time of day differs, so the second line is False.
Date property.noon.Date is midnight of that day, so the last comparison is True.
Frequently Asked Questions
For two DateTime values, yes. Both compare ticks.
No. A Utc and a Local value with the same ticks are equal.
Compare the Date property: a.Date == b.Date.
It returns false. No DateTime equals null.
The time part or the fractions of a second may differ. Equality needs every tick to match.