Quantcast
Viewing latest article 1
Browse Latest Browse All 8

#26 – Null Literal

The keyword null represents a null literal.  A null value indicates that a reference points to no object.

Examples:

 object o1 = null;
 if (o1 == null) Console.WriteLine("Yup, it's null");

 string s1 = null;    // Strings can also be null
 int n1 = s1.Length;  // Throws NullReferenceException, since s1 doesn't point to anything

Filed under: Basics Tagged: C#, Literals, null Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 1
Browse Latest Browse All 8

Trending Articles