Usual methods to check a type is null will result in Null reference exception if an object is checked for null. This post compiles all good and bad methods.

Following methods of checking if an object is null will result in a NullreferenceException.

Wrong method #1

object simpleObject = null;
If(string.IsNullOrEmpty(simpleObject.toString())
{
 // do something if object is null
}
else
{
 //do somethingif object is not null
}

Wrong method #2

object simpleObject = null;
If(simpleObject == null)
{
 // do something if object is null
}
else
{
 //do somethingif object is not null
}

Now the right way to check if an object is null is as follows

object simpleObject = null;
If(object.ReferenceEquals(null, simpleObject)
{
 // do something if object is null
}
else
{
 //do somethingif object is not null
}