c# - T must be contravariantly valid -


what wrong this?

interface irepository<out t> t : ibusinessentity {     iqueryable<t> getall();     void save(t t);     void delete(t t); } 

it says:

invalid variance: type parameter 't' must contravariantly valid on 'mynamespace.irepository.delete(t)'. 't' covariant.

consider happen if compiler allowed that:

interface ir<out t> {     void d(t t); }  class c : ir<mammal> {     public void d(mammal m)     {         m.growhair();     } } ... ir<animal> x = new c();  // legal because t covariant , mammal convertible animal x.d(new fish()); // legal because ir<animal>.d takes animal 

and tried grow hair on fish.

the "out" means "t used in output positions". using in input position.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -