Can you explain what inheritance is and an example of when you might use it?

Showing Answers 1 - 1 of 1 Answers

Roopa

  • Sep 27th, 2005
 

Inheritance helps in the reusability of the code. The class from which another class is derived is called base class. Those methods of the base class can be overridden. The deried class can also implement the methids of the base class. C#.net does not allow multiple inheritance. But multi level inheritance is possible. For eg. Class B derives from Class A, and class C can derive from Class B and so on...

One example in layman terms will be the example of a car. We can define the general features os a car like four tyres, engine poweretc in the base class. The derived class can use this as a base and extend its functionalities like sports car(eg. four wheel drive).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions