Tagged Questions
2
votes
2answers
253 views
Questions about Polymorphism
So I understand the importance of Polymorphism, including how vital it is. But something I don't quite understand is what about the Constructor and any inherited Class the initial Base Class may ...
30
votes
7answers
15k views
When to use abstract classes instead of interfaces with extension methods in C#?
"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived ...
1
vote
3answers
1k views
Abstract class + Inheritance vs Interface
Hello fellow programmers,
I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:"
abstract class ...
9
votes
5answers
2k views
Should all public methods in an abstract class be marked virtual?
I recently had to update an abstract base class on some OSS that I was using so that it was more testable by making them virtual (I could not use an interface as it combined two). This got me thinking ...
2
votes
5answers
267 views
What is the better design decision approach?
I have two classes (MyFoo1 and MyFoo2) that share some common functionality. So far it does not seem like I need any polymorphic inheritence but at this point I am considering the following options:
...
12
votes
2answers
524 views
Abstract exception super type
If throwing System.Exception is considered so bad, why wasn't Exception made abstract in the first place?
That way, it would not be possible to call:
throw new Exception("Error occurred.");
This ...