I have a C# function that is updating a database and need to check to make sure two values in a datarow are not null. I know that ValueA has a value more often than ValueB, so I have a check as follows to make sure I have the most efficient execution (note, using IsNull as a function to check both C# nulls and DBNull.Value):
var value= DataRow["ValueA"];
if (IsNull(value))
{
value= DataRow["ValueB"];
if (IsNull(value))
{
_log.LogError("Error occured while attempting to update a table...");
return;
}
}
Can anyone see a more efficient way to test whether both are null? Is there any way to reduce the number of lines of code but maintain the efficiency?