Date Time Equals - CSharp System

CSharp examples for System:DateTime Time

Description

Date Time Equals

Demo Code


using System.Text;
using System.Collections.Generic;
using System;/*from  w w w  . ja v a2  s  .  co  m*/

public class Main{
        public static bool DateTimeEquls(DateTime? date1, DateTime? date2)
        {
            if (date1 == null)
            {
                return false;
            }
            return DateTimeEquls(date1.Value, date2.Value);
        }
        public static bool DateTimeEquls(DateTime dt, DateTime dt1)
        {
            if (dt.Year != dt1.Year)
                return false;
            if (dt.Month != dt1.Month)
                return false;
            if (dt.Day != dt1.Day)
                return false;
            if (dt.Hour != dt1.Hour)
                return false;
            if (dt.Minute != dt1.Minute)
                return false;
            if (dt.Second != dt1.Second)
                return false;
            return true;
        }
}

Related Tutorials