What are the benefits of using the c# method DataRow.IsNull to determine a null value over checking if the row equals DbNull.value?
if(ds.Tables[0].Rows[0].IsNull("ROWNAME")) {do stuff}
vs
if(ds.Tables[0].Rows[0]["ROWNAME"] == DbNull.value) {do stuff}
There is no real practical benefit. Use whichever one seems more readable to you.
As to the particular differences between them, the basic answer is that
IsNullqueries the null state for a particular record within a column. Using== DBNull.Valueactually retrieves the value and does substitution in the case that it’s actually null. In other words,IsNullchecks the state without actually retrieving the value, and thus is slightly faster (in theory, at least).It’s theoretically possible for a column to return something other than
DBNull.Valuefor a null value if you were to use a custom storage type, but this is never done (in my experience). If this were the case,IsNullwould handle the case where the storage type used something other thanDBNull.Value, but, again, I’ve never seen this done.