Is it possible in C# to create an array of unspecified generic types? Something along the lines of this:
ShaderParam<>[] params = new ShaderParam<&g
You could use a covariant interface for ShaderParam
:
interface IShaderParam { ... }
class ShaderParam : IShaderParam { ... }
Usage:
IShaderParam
But you can't use it with value types like float
in your example. Covariance is only valid with reference types (like string
in my example). You also can't use it if the type parameter appears in contravariant positions, e.g. as method parameters. Still, it might be good to know about this technique.