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

Description

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

Example


using System;//from  w  w  w.  j ava 2  s  .  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 »
    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