From the course: Advanced C#: Object-Oriented Programming
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Defining an abstract class - C# Tutorial
From the course: Advanced C#: Object-Oriented Programming
Defining an abstract class
- Now that we've learned a little bit about what an abstract class is let's try it out in some real code. So let's open up our program file and our vehicles.cs file here in the abstract classes folder. And I have some code that defines a vehicle based class along with two subclasses, one for car and one for motorcycle. The base class has two string properties that represent the make and model of the vehicle and there's a method called sound horn to make the horn sound along with an override of the two string method to represent the vehicle as a string. In my main program file, I have some code that creates a car and a motorcycle and then writes each one to the console and calls the sound horn method. So let's also add some code that creates a vehicle object and we'll write that out to the console. Alright, let's run what we have so far. So we'll bring this up in the terminal. Alright, and in the output you can see the…