C# Equivalent of VB’s IsDBNull


In VB, there is a IsDBNull function that checks to see if a value in a DataReader is null. It’s usage goes something like this:

VB

If IsDBNull(dr("first_name")) = False Then
    ' Do something, first_name is not null
End If

The C# equivalent of this would look something like this:

if (dr["first_name"] != System.DBNull.Value)
{
    // Do something, first_name is not null
}