Nullify Class

This is a cheap class that makes it easier to send DBNull.Value to objects in the System.Data namespace.  You might like this class if you've ever been irritated with if/then/else logic to handle DBNull.Value.  The code is fairly trivial and therefore released to the public domain.  Both C# and VB.NET versions are provided.

Download

Note: Delete the .txt extension after downloading.

Usage

This is a static class with many overloaded methods, such as:

Every static method examines a value and either returns DBNull.Value or the value itself.  Nullable types are recognized and you can designate values that are treated by your program as "null".  For example, if you treat -1 as null, you can call Nullify.Int32(value, -1).

See Also