Why is “null” present in C# and Java?

前端 未结 25 1974
别那么骄傲
别那么骄傲 2020-11-29 22:09

We noticed that lots of bugs in our software developed in C# (or Java) cause a NullReferenceException.

Is there a reason why \"null\" has even been included in the l

25条回答
  •  误落风尘
    2020-11-29 22:45

    One response mentioned that there are nulls in databases. That's true, but they are very different from nulls in C#.

    In C#, nulls are markers for a reference that doesn't refer to anything.

    In databases, nulls are markers for value cells that don't contain a value. By value cells, I generally mean the intersection of a row and a column in a table, but the concept of value cells could be extended beyond tables.

    The difference between the two seems trivial, at first clance. But it's not.

提交回复
热议问题