c# - Why doesn't an interface work but an abstract class does with a generic class constraint? -
the code below shows generic class type constraint ( pub<t> ). class has event can raise allowing pass message subscribers. constraint message must implement imsg (or inherit imsg when it's abstract class). pub<t> provides subscribe method allow objects subscribe notify event if , if object implements ihandler<imsg> . using .net 4, code below shows error on baseimplementer.notifyeventhandler stating that: "no overload 'ihandler<imsg>.notifyeventhandler(imsg)' matches delegate 'system.action<t>'" question: (with updated subscribe method) why error go away change `imsg` abstract class instead of interface? public interface imsg { } // doesn't work //public abstract class imsg { } // work public class msg : imsg { } public class pub<t> t : imsg { public event action<t> notify; public void subscribe(object subscriber) { // subscriber subscribes if implements ihandl...