Compare Date Object - CSharp System

CSharp examples for System:DateTime

Description

Compare Date Object

Demo Code


using Microsoft.SharePoint;
using System.Text;
using System.Linq;
using System.Globalization;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using System;//w  ww.  j  ava2s. c o  m

public class Main{
        public static bool CompareDateObject(object x, object y)
        {
            if (ReferenceEquals(x, y))
            {
                return true;
            }

            if (!(x is DateTime) || !(y is DateTime))
            {
                return false;
            }

            var dt1 = (DateTime) x;
            var dt2 = (DateTime) y;
            return dt1.Date.Equals(dt2.Date);
        }
}

Related Tutorials