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

IsNull

A better IsNull() implementation. Returns true if object value is null or DBNull

Source

public static bool IsNull(this object obj)
{
return obj == null || obj == DBNull.Value || Convert.IsDBNull(obj) == true;
}

Example

string foo = null;
if(foo.IsNull())
{
  //...
}

Author: Manos Aspradakis

Submitted on: 15 jul. 2011

Language: C#

Type: System.Object

Views: 5139