null is a value that can be assigned to various types.
In the example in your question, the type x is User , and the type o is object . For this reason, you can compile Uri u = o , but not Uri u = x . At runtime, the first one will also work, because null is valid for Uri , but the object was not null and User object, this would be an error because this value could not be passed to Uri .
null means "this value is not a reference to an object somewhere in memory." Not being an object at any point in memory, it works regardless of type.
It is also not true that generics will not work, even if you use it in your question.
Generation works with types, not values. Enumerable.Repeat(x, 3) will return an IEnumerable<User> with three null elements, and Enumerable.Repeat(o, 3) will return an IEnumerable<User> IEnumerable<object> with three null elements. The fact that the types of enumerations are different shows that generics will work perfectly here.
source share