C# DateTimeOffset Equals(DateTimeOffset)

Description

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

Syntax

DateTimeOffset.Equals(DateTimeOffset) has the following syntax.


public bool Equals(
  DateTimeOffset other
)

Parameters

DateTimeOffset.Equals(DateTimeOffset) has the following parameters.

  • other - An object to compare to the current DateTimeOffset object.

Returns

DateTimeOffset.Equals(DateTimeOffset) method returns true if both DateTimeOffset objects have the same UtcDateTime value; otherwise, false.

Example

The following example illustrates calls to the Equals(DateTimeOffset) method to test DateTimeOffset objects for equality with the current DateTimeOffset object.


using System;//from  ww  w  . ja  v a 2s .c o m

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

   DateTimeOffset 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