I have some code like:
Lookup(Of String)("Testing")
Lookup(Of Integer)("Testing")
And both of those Lookups work great. What I’m trying to is call the appropriate LookUp based on the type of another variable. Something that would look like…
Lookup(Of GetType(MyStringVariable))("Testing")
I’ve tried to Google this but I’m having a hard time coming up with an appropriate search. Can anyone tell me how to do what I want?
You do not specify the full signature for the method that you’re calling, but my psychic powers tell me that it is this:
And you want to avoid having to repeat
Integertwice as in the example below:The problem is that type parameters are only deduced when they’re used in argument context, but never in return value context. So, you need a helper function with a
ByRefargument to do the trick:With that, you can write: