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
Post a Comment