Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In c# difference between (user==null) and (null==user) [duplicate]

Tags:

c#

Possible Duplicates:
(0 == variable) or (null == obj): An outdated practice in C#?
Why does one often see “null != variable” instead of “variable != null” in C#?

I have seen many times people evaluating null to a variable instead of evaluating variable to a null.

if(null== user)

instead of

if(user==null)

I know both are trying to achieve the same functionality.So,Is it some standard or just pure personal preference. Please comment.

like image 220
Rohit Raghuvansi Avatar asked Nov 26 '22 21:11

Rohit Raghuvansi


1 Answers

user == null is human speak.

null == user is Yoda speak.

To the compiler they are the same, so pick the one you are most comfortable with.

like image 60
Brian Rasmussen Avatar answered Nov 29 '22 12:11

Brian Rasmussen