5

try{
someObject.someAttribute = (int?) reader["columnName"];
}catch{
someObject.someAttribute = null;
}

Or, same coworker, another piece of code:

if(((int?)reader["foo"]).HasValue){
bar = (int?)reader["foo"];
}else{
bar = null;
}

Comments
Add Comment