How to compare only Date without Time in DateTime datatype in C#?

There are times when you might want to compare only the date parts of two DateTime variable in C#.

How to compare only Date without Time in DateTime datatype in C#?

You can easily compare using the Date property from the DateTime object.

using System;
namespace AbundantcodeCsharpSample
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime date1 = DateTime.Now;
            DateTime date2 = DateTime.Now.AddDays(-50);

            if (date1.Date == date2.Date)
                Console.WriteLine("Both the dates are same");
        }
    
    }
  
}