Compare if a value is equal to a specified TimeSpan object in CSharp

Description

The following code shows how to compare if a value is equal to a specified TimeSpan object.

Example


using System;//from w w w . java2 s . c o m

class Sample 
{
    public static void Main() 
    {
        TimeSpan  tsX = new TimeSpan(11, 22, 33, 44); 
        TimeSpan l1 = tsX,   l2 = tsX;
        Console.WriteLine(l1.Equals(l2));
        Console.WriteLine(l1.Equals((Object)l2));
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var