我有一个具有多个属性的类;
public class Employee
{
public string TYPE { get; set; }
public int? SOURCE_ID { get; set; }
public string FIRST_NAME { get; set; }
public string LAST_NAME { get; set; }
public List<Department> departmentList { get; set; }
public List<Address> addressList { get; set; }
}
有时这个对象会返回一个带有任何属性值的值
Employee emp = new Employee();
emp.FIRST_NAME= 'abc';
剩余的值为空,这没问题。
但是,当对象属性中所有值都为空时,我应该如何检查?
就像string.IsNullOrEmpty()
一样,适用于对象吗?
目前,我是这样检查的:
if(emp.FIRST_NAME == null && emp.LAST_NAME == null && emp.TYPE == null && emp.departmentList == null ...)