c# - Why do I need to declare the type? -


i have following code:

public interface imyactionfactory {     abstractaction<t> createaction<t>(myactionparambase parambase = null)         t : myactionparambase; }  public sealed class mergeactionparam : myactionparambase { }  public class mergetest {     private readonly imyactionfactory _actionfactory = new defaultmyactionfactory();      [theory]     [propertydata("mergeworksdata")]     public void mergeworks(/*params here*/)     {         var param = new mergeactionparam();         // populate param here          var sut = _actionfactory.createaction<mergeactionparam>(param);         sut.doaction();     } } 

i getting error

"..error 10 using generic type 'imyactionfactory' requires 1 type arguments..."

why compiler expect type passed imyactionfactory, since have declared interface without t? far method concerned 1 expect type. missing here?

how can make work without redefining interface signature?

edit: feeling bit embarassed here, because quick code put down , ran seperately in standalone online c# compiler doesnt give compilation errors. however, going original solution (tens of projects altogether) error still there.. maybe has xunit ?..not sure

public interface imyactionfactory {     abstractaction<t> createaction<t>(myactionparambase parambase = null)         t : myactionparambase; }  public interface iaction     {         void doaction();     }   public abstract class abstractaction<t> : iaction         t : myactionparambase     {         public void doaction()         {         } }  public class myactionparambase     {          public myactionparambase()         {         }     }  public sealed class mergeactionparam : myactionparambase { }  public class defaultmyactionfactory : imyactionfactory     {         public abstractaction<t> createaction<t>(myactionparambase parambase = null) t : myactionparambase         {             return null;         }     }  public class mergetest {     private readonly imyactionfactory _actionfactory = new defaultmyactionfactory();       public void mergeworks(/*params here*/)     {         var param = new mergeactionparam();         // populate param here          var sut = _actionfactory.createaction<mergeactionparam>(param);         sut.doaction();     } } 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -