c# - Template'd Interfaces Conflicting -


i wondering if there clever trick achieve below code without iusecase<in tinput> , iusecase<out touput> conflicting or simulate these cases.

public interface iusecase<in tinput, out toutput> {    toutput execute(tinput input); }  public interface iusecase<in tinput> {    void execute(tinput input); }  public interface iusecase<out toutput> {     toutput execute(); } 

seems cannot declare 2 generic interfaces same name different template constraints, although cannot find proof in msdn , c# language specification.

compiler emit 'already contains definition' error if 2 types differ covariance modifier, or type constraint. example, following sample not compile well, although generic type have different constraints:

public interface ifoo<t> t : class {   t bar(); }  public interface ifoo<t> t : struct {   void bar(t x); } 

but types considered different if number of generic parameters different.

so answer question - no, cannot that, unless rename interfaces.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -