Array of a generic class with unspecified type

前端 未结 8 820
长发绾君心
长发绾君心 2021-01-11 18:32

Is it possible in C# to create an array of unspecified generic types? Something along the lines of this:

ShaderParam<>[] params = new ShaderParam<&g         


        
8条回答
  •  滥情空心
    2021-01-11 19:09

    No, the concept ShaderParam<> is meaningless as far as an instantiated type is concerned. In other words, a concrete ShaderParam is not an instance of ShaderParam<>. Therefore, the declared type of the array would be illegal for holding that instance. (Above and beyond the fact that it's already illegal syntax to begin with.)

提交回复
热议问题