Check if two DateTimeOffset objects represent the same point in time in CSharp

Description

The following code shows how to check if two DateTimeOffset objects represent the same point in time.

Example


//from w  w w  . j  a  v  a 2  s . c om
using System;

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset firstTime = new DateTimeOffset(2014, 11, 15, 11, 35, 00, 
                                        DateTimeOffset.Now.Offset);
    DateTimeOffset secondTime = firstTime;
    Console.WriteLine("{0} = {1}: {2}", 
                      firstTime, secondTime, 
                      DateTimeOffset.Equals(firstTime, secondTime));
    
  }
}

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