Intellisense gives me an error 'myType' is variable but used like a type
var myType = myObject.GetType();
var result = MyMethod<myType>(param);
Where:
var myObject = new MyType(); // MyType extends MyBaseType
public static string MyMethod<TArgs>(string param)
where TArgs : MyBaseType
{
// Do stuff...
}
So at the runtime the myObject.GetType()
is known (it's MyType
in our case).
Question:
How could I in a right way pass myType
"dynamically" (which in a runtime could be MyType
) to public static string MyMethod<TArgs>(string param)
method?