I'm having some difficulties using generic types. We have a deserialize method which signature looks like this:
Public Function Deserialize(Of T)(ByVal compressedData As Byte()) As T
We have some binary data in database (which can be several types: type1.Question, type2.Question,...). So to prevent having to Select case
in my loop, I tried something like this:
Dim questionType as Type = question.getType()
Deserialize(Of questionType)(question)
This type is not recognized : "Type 'questionType' is not defined"
Is there any way I can achieve this?
I have read and tried Suggestion 1 and Suggestion 2, but for case 1, I cannot use type T as an expression and in case 2, I cannot use "Of type" as that gives in error in the code (the "type is not defined" one).