DateTimeOffset.CompareTo(DateTimeOffset) Method is used to compare the current DateTimeOffset object to a specified DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second DateTimeOffset object.
Syntax: public int CompareTo (DateTimeOffset other);
Here, it takes an object to compare with the current DateTimeOffset object.
Return Value: This method returns a signed integer that indicates the relationship between the current DateTimeOffset object and other.
- Less than zero: Means the current DateTimeOffset object is earlier than other.
- Zero: Means the current DateTimeOffset object is the same as other.
- Greater than zero: Means the current DateTimeOffset object is later than other.
Below programs illustrate the use of DateTimeOffset.CompareTo(DateTimeOffset) Method:
offset1 is later than offset2
offset1 is equal to offset2
- Difference between Method Overriding and Method Hiding in C#
- C# | Math.Max() Method
- C# | Math.Min() Method
- C# | Method Overloading
- C# | Method Parameters
- Extension Method in C#
- C# | Clone() Method
- Decimal.Add() Method in C#
- TimeSpan.Add() Method in C#
- C# | Uri.IsHexEncoding() Method
- C# | Math.Abs() Method | Set - 1
- C# | Math.Abs() Method | Set - 2
- Anonymous Method in C#
- C# | EndsWith() Method
- C# | Math.Exp() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.