Professional Documents
Culture Documents
2024, 7:56 PM
Cheatsheets / Learn C#
C# Inheritance
In C#, inheritance is the process by which one public class Honeymoon : TripPlanner
class inherits the members of another class. The
{ }
class that inherits is called a subclass or derived
class. The other class is called a superclass, or a
base class. // Similar to an interface, inheritance
When you define a class that inherits from
also uses the colon syntax to denote a
another class, the derived class implicitly gains
all the members of the base class, except for its class inherited super class. In this
constructors and finalizers. The derived class case, Honeymoon class inherits from
can thereby reuse the code in the base class
TripPlanner class.
without having to re-implement it. In the derived
class, you can add more members. In this
manner, the derived class extends the // A derived class can only inherit
functionality of the base class.
from one base class, but inheritance is
transitive. That base class may inherit
from another class, and so on, which
creates a class hierarchy.
about:srcdoc Page 1 of 6
19.01.2024, 7:56 PM
C# override/virtual Keywords
about:srcdoc Page 2 of 6
19.01.2024, 7:56 PM
C# protected Keyword
about:srcdoc Page 3 of 6
19.01.2024, 7:56 PM
C# abstract Keyword
about:srcdoc Page 4 of 6
19.01.2024, 7:56 PM
C# Interface
Print Share
about:srcdoc Page 5 of 6
19.01.2024, 7:56 PM
about:srcdoc Page 6 of 6