C# DateTime.AddTicks() Method with Example

DateTime.AddTicks() technique is utilized to restore another date-time object that includes ticks estimation of this occasion.

This article doesn’t change the first estimation of date-time however it restores an item with the new worth.


 DateTime DateTime.AddTicks(long value);

Example to demonstrate example of DateTime.AddTicks() method

using System;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            //Create object of datetime class
            DateTime dt1 = new DateTime(2019,1,1,5,0,15);

            //Adding 5000 ticks using AddTicks method
            DateTime dt2 = dt1.AddTicks(5000);

            //Display ticks of dt1
            Console.WriteLine("Number of ticks in dt1 : " + dt1.Ticks);

            //Display ticks of dt2
            Console.WriteLine("Number of ticks in dt2 : " + dt2.Ticks);



Number of ticks in dt1 : 636819156150000000
Number of ticks in dt2 : 636819156150005000

Leave a Comment

error: Alert: Content is protected!!