Is it possible to create an object of an unknown type? I know that is an ambiguous questions, hopefully this will demonstrate what I am trying to do.
I have an if statement that says:
Well, there are other types it could be, and rather than making an elaborate if statement I was wondering if I could do it dynamically.Code:if recordItem is GetType(InventoryItem) then Dim inventoryItem As InventoryItem = DirectCast(recordItem, InventoryItem) Elseif recordItem is GetType(NonInventoryResaleItem) then Dim inventoryItem As NonInventoryResaleItem = DirectCast(recordItem, NonInventoryResaleItem) End If
I tried using the activator.createInstance method, but I couldn't get it to work the way it showed in MSDN. Is what I want to do possible, or am I thinking crazy?




Reply With Quote