How do you combine abstract classes with interfaces in C#?
Good Morning,
I have a question about comprehension. In C#, we have abstract classes, which are intended as base classes for more specific classes, and then we have interfaces, which serve as a kind of contract or specification. My question is, what would the structure look like if we wanted to combine interfaces and abstract classes? What I think it would look like would be: For example, interface -> worker -> abstract class -> worker -> and then the more specific classes.
From your understanding, everything is true. In your example, however, I would not use I workers and abstract workers. However, I would not have workers as a standard implementation of Iworkers as abstracts, as it always depends on what these classes/interface would like to use.
Another note in the formulation:
Clearly, in the context classes are meant, however, in C# there are also structs (structures) and without context they could also be meant.
Question: What is the difference between abstract classes and interfaces?
If you don't notice a major difference, the question is why you want to use an interface and an abstract class.
A well-known set from the OOD: "Composition over Inheritance".