KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm learning C# coming from C++ and have run into a wall. I have an abstract class AbstractWidget, an interface IDoesCoolThings, and a class which derives from AbstractWidget called RealWidget: public interface IDoesCoolThings { void DoCool(); } public abstract class AbstractWidget : IDoesCoolThings { void IDoesCoolThings.DoCool() { Console.Write("I did something cool."); } } public class RealWidget : AbstractWidget { } When I instantiate a RealWidget object and call DoCool() on it, the compiler gives me an error saying 'RealWidget' does not contain a definition for 'DoCool' I can cast RealWidget object to an IDoesCoolThings and then the call will work, but that seems unnecessary and I also lose polymorphism (AbstractWidget.DoCool() will always be called even if i define RealWidget.DoCool()). I imagine the solution is simple, but I've tried a variety of things and for the life of me can't figure this one out.
Tags (comma-separated)
Save Edits
Cancel