Monday, September 25, 2017

Does C# support multiple inheritance?

C# does not support multiple inheritance (meaning a single class inherits from multiple classes). You can, however, implement multiple interfaces in a single class.
As far as chaining together inherited classes, there isn't a limit per-se. Just keep in mind the complexity you will introduce to your system. When using inheritance, make sure you are using it in a "is a" scenario.

A dog is an animal. A Honda is a car. Otherwise, your inheritance tightly couples your classes with a design that becomes much more difficult to maintain.
If they are static "utility" methods, just invoke them directly without inheriting. Unless those methods belong to the entity you are creating, you should not use inheritance.
Share:

0 comments:

Post a Comment