Compare if this instance is equal to a specified object in CSharp

Description

The following code shows how to compare if this instance is equal to a specified object.

Example


using System;//from w  w  w  . ja  v  a  2 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