0
is there a multi inheritance with C#
c#
2 Respuestas
0
You can'tt inherit multiple classes, but can inherit multiple interfaces
0
Short answer : no.
Long answer : No, but it only means you cannot avec 2 classes from which it inherits. Interfaces were (kinda) created to face this issue.
Interfaces aren't objects, they cannot be instanciated and they don't have a constructor. But they define variables and functions that can be implemented.
For instance, if you want to create a bird, and say it's both an animal and a flying thing, you can create a Bird class that extends Animal and implements Flying. Flying would be an interface in which there could be a flyingSpeed, a flyingAltitude, some functions if you want by example to check if you object isCurrentlyFlying()... Here, the Flying interface could also be used for, say, a plane.