All Questions
Tagged with inheritance c#
8 questions
72
votes
7
answers
81k
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 ...
12
votes
9
answers
4k
views
How can designing for inheritance cause extra cost? [closed]
So I wanted to inherit from a sealed class in csharp and got burned. There is just no way to unseal it unless you have access to the source.
Then it got me thinking "why sealed even exists?". 4 ...
36
votes
9
answers
46k
views
Is it good practice to inherit from generic types?
Is it better to use List<string> in type annotations or StringList where StringList
class StringList : List<String> { /* no further code!*/ }
I ran into several of these in Irony.
20
votes
3
answers
41k
views
Best design for Windows forms that will share common functionality
In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form ...
7
votes
4
answers
2k
views
Can I make my constructors less repetitive?
I'm extending a class with 10 different constructors. The new subclass, SpecialImage, is used like this:
SpecialImage specialImage = new SpecialImage(..);
// Leverage the Rotate() method of ...
2
votes
1
answer
358
views
Repeating Interface inheritance declarations
Take the following example:
public interface ISerialRVD
{
RouteValueDictionary ToRVD();
}
public interface IViewModel : ISerialRVD // Here?
{
Int32 Page { get; set; }
String Action { get;...
1
vote
1
answer
337
views
Implementation of instance testing in Java, C++, C#
For curiosity purposes as well as understanding what they entail in a program, I'm curious as to how instance testing (instanceof/is/using dynamic_cast in c++) works. I've tried to google it (...
1
vote
2
answers
5k
views
share method logic along classes without inheriting from abstract class
In some languages (e.g. C#) a class can only ever have 1 base class which seems like a problem for what I'm trying to do. I will give you an example of what i'm trying to do, hopefully this will make ...