本人刚刚接触C#,在在做三层结构的试验时发现一个问题,DAL层通常需要将DataTable中的字段值赋给一个Entity, 
如:customerEntity.PostCode= (string)dt.Rows[0]["PostCode"]; 但如果此PostCode字段为null值时,将发生错误,因此必须在给customerEntity.PostCode赋值前先进行判断,我的一种做法是在每个赋值时直接判断,如下: 
//当数据库中当前字段值为null时,需要给 
customerEntity.PostCode = dt.Rows[0].IsNull("PostCode") ? String.Empty : (string)dt.Rows[0]["PostCode"]; 
customerEntity.UserID =dt.Rows[0].IsNull( "UserID")?Int64.MinValue: (Int64)dt.Rows[0]["UserID"]; 而我想将这种判断进行一次封装,使上面的表达示为: 
customerEntity.PostCode = GetValue(dt.Rows[0].["PostCode"]); 
customerEntity.UserID =GetValue(dt.Rows[0].["UserID"]); 请问这个GetValue该如何写? 谢!