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# | Remove() Method
- Extension Method in C#
- C# | String.Contains() Method
- C# | CompareOrdinal() Method
- C# | ToLower() Method
- TimeSpan.Add() Method in C#
- Stack.Pop() Method in C#
- Method Hiding in C#
- C# | Method Overriding
- C# | Insert() Method
- C# | Replace() Method
- C# | IsNullOrWhiteSpace() Method
- C# | ToCharArray() Method
- C# | SortedDictionary.Add() 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.