Get Time Span - CSharp System

CSharp examples for System:TimeSpan

Description

Get Time Span

Demo Code


using System.Runtime.InteropServices;
using System;/*from w  w  w  .j av a  2 s .c o m*/

public class Main{
        private static TimeSpan GetTimeSpan(long start, long stop, long frequency)
        {
            var seconds = 1.0d * Math.Max(0L, stop - start) / frequency;
            var ticks = (long)Math.Round(seconds * 10000000d);
            return TimeSpan.FromTicks(ticks);
        }
        public static TimeSpan GetTimeSpan(long start, long stop)
        {
            return GetTimeSpan(start, stop, Frequency);
        }
}

Related Tutorials