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 - C# Tutorial
From the course: C# Essential Training 1: Types and Control Flow
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Understanding classes, structs, and records7m
-
(Locked)
Defining constructors7m 6s
-
(Locked)
Object initialization6m 4s
-
(Locked)
Initialize only properties4m 59s
-
(Locked)
Cloning and copying objects9m 32s
-
(Locked)
Equality comparisons5m 27s
-
(Locked)
Defining abstract classes7m 52s
-
(Locked)
Creating static classes5m 18s
-
(Locked)
Solution: Expressing equality1m 5s
-
-
-
-
-
-