C# DateTimeOffset GreaterThanOrEqual
Description
DateTimeOffset GreaterThanOrEqual
determines whether
one specified DateTimeOffset object is greater than or equal to a second
specified DateTimeOffset object.
Syntax
DateTimeOffset.GreaterThanOrEqual
has the following syntax.
public static bool operator >=(
DateTimeOffset left,
DateTimeOffset right
)
Parameters
DateTimeOffset.GreaterThanOrEqual
has the following parameters.
left
- The first object to compare.right
- The second object to compare.
Returns
DateTimeOffset.GreaterThanOrEqual
method returns true if the UtcDateTime value of left is the same as or later than the UtcDateTime
value of right; otherwise, false.
Example
The GreaterThan method defines the operation of the greater than or equal to operator for DateTimeOffset objects. It enables code such as the following:
/*from ww w . j a v a2s. c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset date1 = new DateTimeOffset(2007, 6, 3, 14, 45, 0,
new TimeSpan(-7, 0, 0));
DateTimeOffset date2 = new DateTimeOffset(2007, 6, 3, 15, 45, 0,
new TimeSpan(-7, 0, 0));
DateTimeOffset date3 = new DateTimeOffset(date1.DateTime,
new TimeSpan(-6, 0, 0));
DateTimeOffset date4 = date1;
Console.WriteLine(date1 >= date2); // Displays False
Console.WriteLine(date1 >= date3); // Displays True
Console.WriteLine(date1 >= date4); // Displays True
}
}
The code above generates the following result.