Int64 - FromTicks
Returns a TimeSpan that represents a specified time, where the specification is in units of ticks.
public static void Main() { Int64 [] values = { 1, 7, 30, 365, 32767, 1234567898765, 12345678987654321, 18012202000000 }; Console.WriteLine("{0,21}{1,18}","FromTicks", "TimeSpan"); Console.WriteLine("{0,21}{1,18}","---------", "--------"); foreach (Int64 value in values) { // C# Extension Method: Int64 - FromTicks TimeSpan interval = value.FromTicks(); string timeInterval = interval.ToString(); int pIndex = timeInterval.IndexOf(':'); pIndex = timeInterval.IndexOf('.', pIndex); if (pIndex < 0) timeInterval += " "; Console.WriteLine("{0,21}{1,26}", value, timeInterval); } }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns a that represents a specified time, where the specification is in units of ticks. /// </summary> /// <param name="value">A number of ticks that represent a time.</param> /// <returns>An object that represents .</returns> public static TimeSpan FromTicks(this Int64 value) { return TimeSpan.FromTicks(value); } }