mercredi 7 décembre 2016

Getting a Property list with similar name for looping c#

I have a class with several properties

public class Hotel
{
   public string ID {get; set;}
   public string Name {get; set;}
   public string Location {get; set;}
   public Image Image1 {get; set;}
   public Image Image2 {get; set;}
   public Image Image3 {get; set;}
   public Image Image4 {get; set;}
}

I want to get a list of all the properties starting with property name "Image" ex

public List<Image> GetImageList(Hotel hotel)
{
  List<Image> imageList = new List<Image>();
  foreach(var item in <ImageList>)
  {
    rest of the code .....
  }

  return imageList ;
}





Aucun commentaire:

Enregistrer un commentaire