IsNullOrDBNull

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();

Description

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.

Details

Double click on the code to select all.

 

;