In C # you cannot do
if (MyObject)
to check for null s. This is a compile-time error (if the class does not have an implicit logical conversion operator).
if (!MyObject)
also invalid if the class does not overload operator ! to return a boolean value (or a value that can be implicitly entered into a boolean value).
So you have to stick with obj == null and obj != null .
To summarize, a non-subjective reason is the ability to compile your code!
UPDATE (story):
There used to be no bool type in ancient C. Zero was considered false , and each nonzero value was considered true . You can write
while(1) { }
to create an endless loop.
You can also do things like
int n = 10; while (n--) { }
to have a loop that executes n times. The problem with this strategy was this:
int x = 10; if (x = 0) {
You missed one character and you created an error (most modern C compilers will give a warning about this statement, but it is still C).
That's why you see code like
if (5 == variable) if (NULL == pObj)
in many places since it is not subject to the above error.
C # developers decided to require a logical expression as a condition for if , while , etc., and not to allow casting of types (unless they explicitly declare an overloaded operator that is discouraged), to eliminate the possibility of errors. So things like:
object x = null; if (x) { } int y = 10; if (y) { } while (y--) { }
which are valid in C do not compile in C # at all .
It is not a matter of style or agreement in any way.