C# DateTime DateTime(Int64)

Description

DateTime DateTime(Int64) initializes a new instance of the DateTime structure to a specified number of ticks.

Syntax

DateTime.DateTime(Int64) has the following syntax.


public DateTime(
  long ticks
)

Parameters

DateTime.DateTime(Int64) has the following parameters.

  • ticks - A date and time expressed in the number of 100-nanosecond intervals that have elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.

Example

The following example demonstrates one of the DateTime constructors.


using System;/*  w  w w .j a v  a 2 s . co  m*/
using System.Globalization;

class Sample 
{
    public static void Main() 
    {
        DateTime dt1 = new DateTime(DateTime.MaxValue.Ticks);

        Console.WriteLine(dt1);
    }
}

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