ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


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.


public static bool IsNullOrDBNull(this object obj)
    if (obj == null || obj.GetType() == typeof(DBNull))
        return true;
        return false;


Object obj = null;
bool b = obj.IsNullOrDBNull();

Author: Hadi Lababidi

Submitted on: 19 feb 2010

Language: C#

Type: System.Object

Views: 5949