c# - Why do I get the following error? Invalid variance modifier. Only interface and delegate type parameters can be specified as variant -


 using system;  using system.collections.generic;  using system.linq;  using system.text;  namespace variance  {   class { }    class b : { }    class c<out t>  { }  class program {     static void main(string[] args)     {         var v = new c<b>();          ca(v);     }      static void ca(c<a> v) { }   } } 

this offending line:

class c<out t>  

as error message tells you, can't apply generic variance classes, interfaces , delegates. okay:

interface c<out t> 

the above not.

for details, see creating variant generic interfaces


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -