Check if DateTimeOffset object represents the same point in time as a specified object in CSharp

Description

The following code shows how to check if DateTimeOffset object represents the same point in time as a specified object.

Example


using System;/* ww  w . ja  v a2  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 »
    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