C# DateTimeOffset Equality
Description
DateTimeOffset Equality
determines whether two specified
DateTimeOffset objects represent the same point in time.
Syntax
DateTimeOffset.Equality
has the following syntax.
public static bool operator ==(
DateTimeOffset left,
DateTimeOffset right
)
Parameters
DateTimeOffset.Equality
has the following parameters.
left
- The first object to compare.right
- The second object to compare.
Returns
DateTimeOffset.Equality
method returns true if both DateTimeOffset objects have the same UtcDateTime value; otherwise,
false.
Example
The Equality method defines the operation of the equality operator for DateTimeOffset objects. It enables code such as the following:
/* w w w.j ava 2 s .co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset date1 = new DateTimeOffset(2014, 6, 3, 14, 45, 0,
new TimeSpan(-7, 0, 0));
DateTimeOffset date2 = new DateTimeOffset(2014, 6, 3, 15, 45, 0,
new TimeSpan(-6, 0, 0));
DateTimeOffset date3 = new DateTimeOffset(date1.DateTime,
new TimeSpan(-6, 0, 0));
Console.WriteLine(date1 == date2);
Console.WriteLine(date1 == date3);
}
}
The code above generates the following result.