This may be rather obvious but I can't seem to get it. For a rather convoluted refactoring (a.k.a hack) I need to be able to swap out the 'type' of list based on some flags. To make the swap easier and prevent "downstream" changes of nested functions I decided to do something like this:
List<Object> myList = new List<Tuple<string, bool>>();
Based on certain flags I'd like to do this instead:
List<Object> myList= new List<MyObject>();
That way I can use myList
almost as is without too many changes in the methods that consume the list. In most cases they only add elements to the list and not read from it so this 'hack' would be rather convenient.
However, I can't really seem to do this as the C# compiler complains that it cannot cast from System.Tuple
to Object
. What really am I missing?