0

I am trying to take properties from a list of types and put them in another list. I am not exactly sure how you iterate through the list of objects to gain access to the properties.

For example:

List<images> myImages = new List<images>();

List<string> typeOfImage = new List<string>();

typeOfImage.Add(myImages.type);

Can someone help me in this?

A Coder
  • 3,039
  • 7
  • 58
  • 129
  • Just Look at [Here](http://stackoverflow.com/questions/557340/c-sharp-generic-list-t-how-to-get-the-type-of-t) – RajeshKdev Apr 19 '13 at 07:22

2 Answers2

4

Try this:

typeOfImage = myImages.Select(image => image.AnyPropertyYouNeed).ToList();
petro.sidlovskyy
  • 5,075
  • 1
  • 25
  • 29
0
if (myImages.Count < 0)
   typeOfImage.Add(myImage[0].GetType().ToString());
ferdyh
  • 1,355
  • 2
  • 11
  • 29