c# - Do generic classes have a base class? -
i pass generic interface function:
private i<t> createstubrepository<t, >() : agenericbaseclass
so wondering if generic interfaces implement base class or specific interface?
i know using reflection can test if generic class dont see helping me
well. what's point of forcing usage of any interface? not (or question).
you should more this:
public interface imyrepository<t> { } public class repository<t> : imyrepository<t> { } private imyrepository<tentity> createstubrepository<tentity>() { return new repository<tentity>(); } var repos = createstubrepository<user>();
update
thanks answer thats not asking. want know class implements generic interface have base class or inherit interface? dont want force interface more question of object passed generic
classes not inherit interfaces. implement them. different subtle important.
a class can inherit class. means if not specify class inherits still inherit object. , wont change no matter how many interfaces class implement.
class myclass : icoolinterface // inherits object class mylist : arraylist, isomeinterface // inherits arraylist class mygenericlist<t> : ilist<t> // inherits object.
Comments
Post a Comment