IsNullOrDBNull
We all know that objects can be null, but when dealing with databases, a new null type shows up, the DBNull. This extention method detects it along with the null.
Source
public static bool IsNullOrDBNull(this object obj)
{
if (obj == null || obj.GetType() == typeof(DBNull))
return true;
else
return false;
}
Example
Object obj = null;
bool b = obj.IsNullOrDBNull();