Chapter 6. Inheritance: Your Object’s Family Tree


Sometimes you DO want to be just like your parents.

Ever run across a class that almost does exactly what you want your class to do? Found yourself thinking that if you could just change a few things, that class would be perfect? With inheritance, you can extend an existing class so your new class gets all of its behavior—with the flexibility to make changes to that behavior so you can tailor it however you want. Inheritance is one of the most powerful concepts and techniques in the C# language: with it, you can avoid duplicate code, model the real world more closely, and end up with apps that are easier to maintain and less prone to bugs.

Calculate damage for MORE weapons


Do this!

The updated sword damage calculator was huge a hit on game night! Now Owen wants calculators ...

Get Head First C#, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.