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