Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator '&&' cannot be applied to operands of type 'System.DateTime' and 'System.DateTime'

Tags:

c#

I thought this would work, but apparently it doesn't. Any suggestions please?

if (c.ArrivalTime = DateTime.MinValue && c.ExpiryTime = DateTime.MinValue)
{

}

then I got this, Operator '&&' cannot be applied to operands of type 'System.DateTime' and 'System.DateTime'

like image 787
Ray Avatar asked Jul 31 '12 23:07

Ray


Video Answer


2 Answers

You need to use == for equality operations in C#.

Please see section 1.4 Expressions in the C# language specification.

like image 114
Bryan Crosby Avatar answered Sep 22 '22 13:09

Bryan Crosby


you are missing equality operator ==

Please use this way

if (c.ArrivalTime == DateTime.MinValue && c.ExpiryTime == DateTime.MinValue)
like image 45
HatSoft Avatar answered Sep 19 '22 13:09

HatSoft