Doing Foreach construct on unknown types at runtime
Posted on 2007-03-21
I have a method which has a parameter of type IList<myType>.
I would like the method to determine what type is 'myType' (which I can already do),
then iterate over the list using a foreach construct. The problem is I cannot declare
the foreach(myType t in IList) because I don't have an object of the unknown type
myType passed in. If we knew that the type of 'myType' was type 'FooBar' then I could
write the following:
foreach(Foobar fb in myIList)
How can I get a the named type and use it as shown above?