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#
- Queue.Contains() Method in C#
- C# | ToCharArray() Method
- Stack.Contains() Method in C#
- Stack.Pop() Method in C#
- TimeSpan.Add() Method in C#
- C# | IsNullOrWhiteSpace() Method
- C# | CompareOrdinal() Method
- C# | SortedDictionary.Add() Method
- C# | StartsWith() Method
- DateTime.Add() Method in C#
- C# | Copy() Method
- C# | ToLower() Method
- C# | ToUpper() Method
- C# | Math.Abs() Method | Set - 2
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.