How to Iterate the List in Reflection.

May 10 2011 9:00 AM
Hi all,

I need a help on Reflection.

I am facing a problem while Iterating the List in reflection.

  var item = property.GetValue(obj,null); //This will return List of Student. Actually We dont know the type of obj ie Student, as it is in Reflection.
 
  foreach(var value in (item as IEnumerable))
  {
  //Do stuff
  }

if i do like this i am getting error like,

Using the generic type 'System.Collections.Generic.IEnumerable<T>' requires 1 type arguments


Please help me.

Answers (2)