Write C# Program to Compare Two Dates

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading;

using System.Threading.Tasks;

using System.Xml;


namespace ConsoleApp

{

    class Program

    {

        static void Main(string[] args)

        {

            DateTime date1 = new DateTime(2025, 05, 22);

            DateTime date2 = new DateTime(2025, 05, 30);

            if (date1 < date2)

            {

                Console.WriteLine("date1 is earlier than date2.");

            }

            else

            {

                Console.WriteLine("date1 is later than date2.");

            }

            Console.ReadKey();


        }

    }

}


Output:-

date1 is earlier than date2.


एक टिप्पणी भेजें

0 टिप्पणियाँ