C# – Simple example of inheritance

Reading the C# 6.0. book for which I am preparing a review made  me think that I do not post a lot of C#  code. Thus, I have decided to prepare a simple C# example of inheritance with overriding. Let’s see what would happen 🙂

Pretty much, we have 3 classes – Food, Pizza and Pepperoni.

Pepperoni is a pizza. Pizza is a food. In each class we have the method “Prepare”. In Food is says “Preparing Food.”. In Pizza, it says “Prepare Pizza”. And in Pepperoni it takes the one from the Pizza and adds “Pepperoni. This is simple enough! 🙂

Looks like this:

Pizzas

 

The code is this one:

And that is enough! Mahlzeit! 🙂

About

VBA Developer

Tagged with: ,