Tuesday, 24 June 2014

Code to Get Time Difference Between Two Times In C#

6/24/2014 - By Pranav Singh 0

In this article I will show you how you can get the difference of time in hours between two times using C#.Nert. It’s a console application used for demo.


So for this article first we will create a new console application and add the below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TimeDifference
{
    class Program
    {
        /// <summary>
        /// Code to Get Time Difference Between Two Times In C#
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string yourStartTime = "11:00 AM";
            string yourEndTime = "5:00 PM";

            TimeSpan durationreamin = DateTime.Parse(yourEndTime).Subtract(DateTime.Parse(yourStartTime));
            Console.WriteLine("**Code to Get Time Difference Between Two Times In C#**\n");
            Console.WriteLine("Time difference : " + durationreamin);
            Console.ReadLine();
        }
    }
}

Now run the application


Tags:
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top