Weird behavior with Unity Object (in C#)

so I have the following code
Debug.Log(new Object() == null);

and it prints True on the console. Why is a non-null new Object equal to null?

It prints False here (Unity 3.4).

There’s something wrong in this case: I tested it in javascript in Awake and Start and it returned false, as expected. Where are you placing this code?

Object is a base class, only used to help create real classes, meaning you can’t create just an “Object” and wouldn’t want to. It’s like asking for a pet “mammal.” So, new Object(); can’t work. Instead of crashing (or guessing that you want a dog,) it does nothing and returns null (Unity 3.4.1f5, C#.)

My guess is that since javascript allows you to mutate types on the fly, javascript new Object() shrugs and creates a useless Object, since it might get twisted into something worthwhile. In C#, create a GameObject, or a Transform, or whatever it is you actually want.

Why do that unusable base-class stuff? The same reason we define mammal. We save lots of time saying cats, dogs and cows are mammals, then describing things about mammals once. Likewise, programs save time saying that Transforms, PerticleEmmiters … are Objects and describing Objects once. Why does C# have stricter rules than javascript? Catches more errors and runs faster.