Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does null inherit from Object as well in C#?

Tags:

c#

.net

Does null inherit from Object as well in C#?

Where does the null itself defined?

like image 295
Joan Venge Avatar asked Feb 20 '09 19:02

Joan Venge


2 Answers

Does null inherit from Object as well in C#?

Unlike in some other systems, null is not defined in terms of a class or an instance. On the contrary, it signifies the absence of any instance, and it doesn't have a type. It is implicitly converted to whatever reference type fits the context. The widest conversion (i.e. when no other can be inferred) is to object. But still, null is not generally of type object.

like image 164
Konrad Rudolph Avatar answered Sep 21 '22 06:09

Konrad Rudolph


null is not an object - it is a language keyword that denotes the lack of an object reference.

like image 37
Andrew Hare Avatar answered Sep 21 '22 06:09

Andrew Hare