Why is null not allowed for DateTime in C#?

DateTime is a value-type (struct), where-as string is a reference-type (class etc). That is the key difference. A reference can always be null; a value can’t (unless it uses Nullable<T> – i.e. DateTime?), although it can be zero’d (DateTime.MinValue), which is often interpreted as the same thing as null (esp. in 1.1).

Create Non-Nullable Types in C#

Yes, these are called struct. Structs are value types, just like int, bool and others. They have some rules/recommendations related to them: (I think these are the most important) a struct is passed and assigned by value, when not using ref or out keywords… this means that everything you put inside a struct will be … Read more

In Kotlin, what is the idiomatic way to deal with nullable values, referencing or converting them

First, you should read all about Null Safety in Kotlin which covers the cases thoroughly. In Kotlin, you cannot access a nullable value without being sure it is not null (Checking for null in conditions), or asserting that it is surely not null using the !! sure operator, accessing it with a ?. Safe Call, … Read more

Best explanation for languages without null

I think the succinct summary of why null is undesirable is that meaningless states should not be representable. Suppose I’m modeling a door. It can be in one of three states: open, shut but unlocked, and shut and locked. Now I could model it along the lines of class Door private bool isShut private bool … Read more