Hi all of SO users I'm having little confusion with understanding null and Empty. I know null is special case, which is not equal to itself. I want to know how to determine that it is null, on what basis you are telling it is null, and the same for empty also
Just I want know how the compiler come to know it is NULL or Empty.
null
is a special reference that means 'not referencing anything'
Empty only applies to collections (and a string is a collection of char). It means there is a valid collection but it contains no (0) elements.
When returning a collection it is usually better to return an empty collection instead of null.
When receiving a collection, decide whether null
should be treated as an empty collection. This depends on the situation, agreements and promises made etc.
i know null is special case, which is not equal to itself
Not entirely true. null == null
is always true.