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.Abs() Method | Set - 1
- C# | Math.Abs() Method | Set - 2
- C# | Math.Exp() Method
- C# | Trim() Method
- C# | Dictionary.Add() Method
- C# | StartsWith() Method
- DateTimeOffset.Add() Method in C#
- C# | PadLeft() Method
- C# | Method Overriding
- C# | Join() Method | Set - 1
- C# | Method Overloading
- C# | IndexOfAny() Method
- Decimal.Add() Method in C#
- C# | Replace() 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 firstname.lastname@example.org. 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.