The http://msdn.microsoft.com/zh-cn/library/system.datetimeoffset.ticks (VS.95). aspx
Gets the number of time cycles, which indicates the date and time of the Current DateTimeOffset object in the clock time.
TicksThe property is not affected by the Offset property value.
TicksThe value of the attribute indicates the number of intervals (MinValue value) between January 1, 0001 nanoseconds that have elapsed since midnight, January 1, 100 .). One nanoseconds equals one thousandth of a second; one second includes 10 million time cycles.TicksThe property value isDateTimeOffset. MinValue. TicksAndDateTimeOffset. MaxValue. Ticks.
By using the DateTimeOffset (Int64, TimeSpan) constructor overload, you can allocate the number of time periods to the DateTimeOffset object.
The following example initializes the DateTimeOffset object by estimating the number of time cycles in the date (July 1, 2008 1:23:07. It then displays the date and the number of time cycles represented by the date on the console.
// Attempt to initialize date to number of ticks
// In July 1, 2008 1:23:07.
//
// There are 10,000,000 100-nanosecond intervals in a second
Constlong NSPerSecond = 10000000;
Long ticks;
Ticks = 7 * NSPerSecond; // Ticks in a 7 seconds
Ticks + = 23*60 * NSPerSecond; // Ticks in 23 minutes
Ticks + = 1*60*60 * NSPerSecond; // Ticks in 1 hour
Ticks + = 60*60*24 * NSPerSecond; // Ticks in 1 day
Ticks ++ = 181*60*60*24 * NSPerSecond; // Ticks in 6 months
Ticks + = 2007*60*60*24 * 365L * NSPerSecond; // Ticks in 2007 years
Ticks ++ = 486*60*60*24 * nspersecond; // adjustment for leap years
Datetimeoffset DTO = new datetimeoffset (
Ticks,
Datetimeoffset. Now. offset );
Outputblock. Text + = string. Format ("there are {0: N0} ticks in {1 }.",
Dto. ticks,
Dto. tostring () + "\ n ";