From the course: C# Essential Training 1: Types and Control Flow

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Defining abstract classes

Defining abstract classes

- [Instructor] We've seen how to create types and even some derivation and interface implementation. I want to shift to talk about abstract classes. So I've still got my IPerson interface here, but I've simplified it, with just first name and last name. And I've got an abstract class called Employee. Because it's abstract, I can't create an instance of the Employee class, but I'm defining it as a base class for others to implement. So we've got our properties from the interface. We've got a StartDate that's a property. And then we get into the abstract part here. Now I have properties and I have methods. And if you recall, when we do properties that get and set, though, we often just simplify them like I've done here, actually result in methods. We have a get EndDate and a set EndDate method. So those, just like regular methods, can be marked as either virtual or abstract. Now abstract, as we see here for the ProcessPayroll method on line 24 means that this class, the base class does…

Contents