I am trying to a catch nullreference exception but I want to know the exact location (at which point or line I am getting that exception). I have one class named Employee
and it has two properties: _Id
and _Name
.
static void Main(string[] args)
{
Employee empobj = new Employee();
try
{
empobj = null;
//empobj._Id = empobj._Id.ToString();
Console.WriteLine(empobj._Id);
Console.WriteLine(empobj._Name);
Console.ReadLine();
}
catch (NullReferenceException e)
{
Console.WriteLine("Exception caught: {0}", e.InnerException);
Console.ReadLine();
}
}