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#
- Decimal.Add() Method in C#
- C# | CopyTo() Method
- C# | ToUpper() Method
- C# | Dictionary.Add() Method
- C# | EndsWith() Method
- Main Method in C#
- C# | StartsWith() Method
- C# | Math.Max() Method
- C# | Math.Log() Method
- C# | Trim() Method
- C# | Math.Min() Method
- C# | PadRight() Method
- C# | Method Overriding
- C# | Copy() 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.