Wants to retrieve all properties of class using reflection. Please find below example. When I retentive properties of MainClass, I want to have list of all properties of Person and Employee class.
I am having multiple objects just like MainClass. there could be N number of properties inside this class and i want to have list of all properties of the class. If property is object, in that case object's properties are required. I want to have a function for this which will accept dynamic model and will return all properties.
Please help.
public class Person
{
public string FirstName { get;set; }
public string LastName { get;set; }
public string City { get;set; }
}
public class Employee
{
public string EmpCode { get;set; }
public string CompanyName { get;set; }
public string DepartmentName { get;set; }
}
public class MainClass
{
public Person PersonInfo { get; set; }
public Employee EmployeeInfo { get; set; }
}
Aucun commentaire:
Enregistrer un commentaire