Q:

Explain Inheritance in C# with an example?

0

Explain Inheritance in C# with an example?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Inheritance allows us to define a class that inherits all the methods and attributes from another class. The class that inherits from another class is called a derived class or child class. The class from which we are inheriting is called parent class or base class.

There are many benefits of inheritance in C#, so let us see them:

  • Inheritance provides code reusability, makes it easier to create and maintain an application. So we don’t have to write the same code again and again.
  • It allows us to add more features to a class without modifying it.
  • It is transitive in nature, which means that if class B inherits from another class A, then all the subclasses of B would automatically inherit from class A.
  • Inheritance represents real-world relationships well.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the best way to give a C# auto-property an... >>
<< What is serialization?...