mercredi 19 août 2015

Auto detect the type of reference property of a given class object

Given a class like this

public class Employee
{
   public Employee()
   {
       Children = new List<Child>();
   }
   public virtual string FirstName { get; set; }
   public virtual string LastName { get; set; }
   public virtual EmployeeCard EmployeeCard { get; set; }
   public virtual IList<Child> Children { get; protected set; }
}

If I have an object of the above class, how to determine if the EmployeeCard property is an object or a list of object at run time? Is this possible?





Aucun commentaire:

Enregistrer un commentaire