This method is used to compare two TimeSpan values and returns an integer value which indicates whether the first value is shorter than, equal to, or longer than the second value.
Syntax: public static int Compare (TimeSpan t1, TimeSpan t2);
t1: Specifies the first time interval that will be compared.
t2: Specifies the second time interval that will be compared.
-1: If t1 is shorter than t2.
0: If t1 is equal to t2.
1: If t1 is longer than t2.
Below programs illustrate the use of TimeSpan.Compare(TimeSpan, TimeSpan) Method:
t1 is greater than t2
t2 is greater than t1
t1 is equal to t2
- Difference between Method Overriding and Method Hiding in C#
- C# | Clone() Method
- C# | Math.Abs() Method | Set - 1
- C# | Math.Abs() Method | Set - 2
- C# | Math.Exp() Method
- C# | IndexOfAny() Method
- C# | Math.Sin() Method
- Decimal.Add() Method in C#
- C# | Dictionary.Add() Method
- C# | Math.Cos() Method
- C# | Math.Tan() Method
- C# | String.Contains() Method
- C# | Math.Min() Method
- C# | Insert() Method
- C# | Random.Next() 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.