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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -