What is a Null literal in C#?

 Posted by Goud.Kv on 9/3/2014 | Category: C# Interview questions | Views: 1214 | Points: 40

Null literal is a null type which indicates that the reference is pointing to no object.

public class Employee

int name, id;
static void Main()
Employee emp = null;
In the above example, we have an Employee class.
emp is an object created to Employee.
But it is not referring to any object.

If we try to call the variables like,

will throws an error at the runtime which is known as Null Reference Exception.

Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response