SqlDataReader Best way to check for null values -sqlDataReader.IsDBNull vs DBNull.Value
问题 I want to retrieve decimal values from the database and I would like to know which is the recommended way to check for null values. I have seen on MSDN - DBNull.Value Field that this check is rarely used. Thus, is the reader.IsDBNull the best/most efficient way to check for nulls? I have created 2 sample methods: public static decimal? GetNullableDecimal(SqlDataReader reader, string fieldName) { if (reader[fieldName] == DBNull.Value) { return null; } return (decimal)reader[fieldName]; }