samedi 18 avril 2020

how can I set the value of multiple List in class using reflection?

I want to set the value of some properties using reflection.

  public class ResultContent
    {
        public List<Cars> AllCars { get; set; }
        public List<Colors> AllColors { get; set; }
    }
    public class Colors
    {
        public string Name { get; set; }
        public string Color { get; set; }
    }
    public class Cars
    {
        public string CarName { get; set; }
        public int Speed { get; set; }
    }

    foreach (var prop in typeof(ResultContent).GetProperties())
    {

    }

how can I set the properties inside the List for example inside the List<Cars>





Aucun commentaire:

Enregistrer un commentaire