C# TimeSpan Equals(TimeSpan, TimeSpan)

Description

TimeSpan Equals(TimeSpan, TimeSpan) returns a value that indicates whether two specified instances of TimeSpan are equal.

Syntax

TimeSpan.Equals(TimeSpan, TimeSpan) has the following syntax.


public static bool Equals(
  TimeSpan t1,
  TimeSpan t2
)

Parameters

TimeSpan.Equals(TimeSpan, TimeSpan) has the following parameters.

  • t1 - The first time interval to compare.
  • t2 - The second time interval to compare.

Returns

TimeSpan.Equals(TimeSpan, TimeSpan) method returns true if the values of t1 and t2 are equal; otherwise, false.

Example

The following example compares several TimeSpan objects to a reference TimeSpan object using the static Equals method.


using System;//w  w  w.j  a v a  2  s  .  co  m

class TSCompareEqualsDemo
{
    static void Main( )
    {
        TimeSpan Left = new TimeSpan( 2, 0, 0 );

        Console.WriteLine(TimeSpan.Equals( Left, new TimeSpan( 0, 120, 0 ) ) );
    } 
} 

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version