I am trying to play with Reflection and ran into the following situation.
In the following code, let\'s assume that the \'obj\' can be of types IEnumerable<>
Well, since you don't know the actual type of the items until runtime, you don't need to use the generic IEnumerable
interface; just use the non-generic one, IEnumerable
(the generic one inherits from it):
private void WriteGenericCollection(object obj)
{
IEnumerable enumerable = (IEnumerable)obj;
foreach(object item in enumerable)
{
...
}
}