[edit] TimeSpan Ticks Property
The TimeSpan Ticks property simply returns the Ticks field in the TimeSpan object. It returns a Long which means it can return only positive values.
[edit] Syntax
object.Ticks()
[edit] Example 1:
using System;
class Program
{
static void Main()
{
DateTime now = DateTime.Now;
DateTime then = new DateTime(2004, 12, 3, 4, 0, 12, 127);
TimeSpan diff = now - then;
Console.WriteLine(diff.Ticks.ToString());
Console.Read();
}
}
Output:
746158142480000
The code simply subtracts the now date from the then date and it returns a timespan value. Then the diff object is used to extract the Ticks part from the TimeSpan object.
- Note: This does not return the total Ticks from a timspan object.
<-- TimeSpan Tutorial
|