Supposing I have:
public Dictionary<CertainEnum, Type> myDictionary = new()
{
{ CertainEnum.A, typeof(Class1) },
{ CertainEnum.B, typeof(Class2) }
}
How could I call a method that uses generics using this dictionary? I tried to declare 'testVariable' as either a 'Type' or 'dunamic', but the error is the same: 'testVariable is a variable but is is used like a type'.
public class MyClass<T>
{
public List<T> MyMethod()
{
return new List<T>();
}
}
dynamic testVariable = myDictionary[CertainEnum.A];
var result = MyClass.MyMethod<testVariable>();
By reading this extensive post:
... what I was not able to find is how to deal with the fact that 'result' gets a List.