Array of a generic class with unspecified type

前端 未结 8 819
长发绾君心
长发绾君心 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:01

    That wouldn't make sense.

    What would happen if you write params[3]?
    What type would it be?

    You may want to create a non-generic base class or interface and use an array of them.

提交回复
热议问题