Trying to put a generic MyObj<T, U> into an IList where U can be different between objects
- by Sergio Romero
I have the following class definition:
public interface IItem{}
public class FirstObject<T, U> : IItem
{
public U SomeProperty { get; private set; }
}
IList<IItem> myList = new List<IItem>();
I did it like this because U can be of different types. Now I want to iterate the list and get my items back, the problem is that I do not know how to cast them back to their original type so I can read the value of SomeProperty.
Thanks for your help.