C# DateTimeOffset Equals(Object)

Description

DateTimeOffset Equals(Object) determines whether a DateTimeOffset object represents the same point in time as a specified object.

Syntax

DateTimeOffset.Equals(Object) has the following syntax.


public override bool Equals(
  Object obj
)

Parameters

DateTimeOffset.Equals(Object) has the following parameters.

  • obj - The object to compare to the current DateTimeOffset object.

Returns

DateTimeOffset.Equals(Object) method returns true if the obj parameter is a DateTimeOffset object and represents the same point in time as the current DateTimeOffset object; otherwise, false.

Example

The following example indicates whether the current DateTimeOffset object is equal to other DateTimeOffset object.


using System;/*from  www  . j  av a 2  s  .co m*/

public class MainClass{
  public static void Main(String[] argv){  
   DateTimeOffset firstTime = new DateTimeOffset(2007, 9, 1, 6, 45, 0, 
                              new TimeSpan(-7, 0, 0));

   object secondTime = firstTime;
   Console.WriteLine("{0} = {1}: {2}", 
                     firstTime, secondTime, 
                     firstTime.Equals(secondTime));

  }
}

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