What is inheritance in C#?

Answer

Inheritance is an OOP principle where a class (derived/child class) inherits members (fields, methods, properties) from another class (base/parent class), enabling code reuse and establishing an "is-a" relationship. In C#: class Dog : Animal { }. Key rules: (1) C# supports single inheritance for classes (a class can only have one base class). (2) Multiple inheritance is supported via interfaces. (3) Use base keyword to call the base class constructor or methods: base.Method(). (4) sealed class prevents further inheritance. (5) abstract class cannot be instantiated and may have abstract members that must be overridden. (6) virtual methods can be overridden in derived classes; override keyword replaces the implementation. Every class ultimately inherits from System.Object.