Its a very easy concepts, finding traveling time, which is travel by a train. Suppose your train arrival Date and time is 2/9/2014 10:47:00 PM and departure date time is 2/8/2014 6:32:00 PM . Now, you want to get total traveling time. Use TimeSpan Structure for getting elapsed time. Lets take an simple example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
DateTime departure = new DateTime(2014, 2, 8, 18, 32, 0);
DateTime arrival = new DateTime(2014, 2, 9, 22, 47, 0);
TimeSpan travelTime = arrival - departure;
Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime);
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
DateTime departure = new DateTime(2014, 2, 8, 18, 32, 0);
DateTime arrival = new DateTime(2014, 2, 9, 22, 47, 0);
TimeSpan travelTime = arrival - departure;
Console.WriteLine("{0} - {1} = {2}", arrival, departure, travelTime);
Console.ReadKey();
}
}
}