asp.net - Using <T> on IPagination -


i have following class

  public class navigationientity     {         public int currentid { get; set; }         public string view { get; set; }         public string controller { get; set; }         public ipagination<ientity> entities  { get; set; }      } 

i have following helper instantiate

public static navigationientity create<t>(int currentid, string view, string controller, ipagination<t> entities) t : ientity  {       return new navigationientity {        entities = entities, view = view, controller = controller, currentid = currentid       }; } 

however following error.

enter image description here

edit: i've tried following, "ipagination entities" ie not t

public static navigationientity create(int currentid, string view, string controller, ipagination<ientity> entities) {                 return new navigationientity { entities = entities, view = view, controller = controller, currentid = currentid }; } 

but don't know how best resolve

enter image description here

distributionunit implements ientity

you're passing generic type non generic "slot". (entities explicitly ientity)

generics where compiler check, checks you're using object right.

it not guarantee object of type @ run time.

in case, because it's explicit anyway, can do:

public static navigationientity create<t>(int currentid, string view, string controller, ipagination<ientity> entities) 

it work inherits ientity anyway.

or, can little cheat, keep signature same, want:

   public static navigationientity create<t>(int currentid, string view, string controller, ipagination<t> entities) t : ientity     {         return new navigationientity         {             entities = entities ipagination<ientity>,             view = view,             controller = controller,             currentid = currentid         };     } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -