C# Abstract Classes - What They Are, How to Use Them, and Best Practices

preview_player
Показать описание
I get asked about abstract classes a lot. What they are, how they work, and why you should know about them. An easy way to think of an abstract class is to say that it fits between a full base class and an interface. Basically, it is a blend of the two. In this video, I am going to demonstrate what an abstract class is, how to use it, and when it makes sense to create an abstract class.

Sponsors:
Tuhafeni Angula (Patreon Subscriber)

0:00 - Intro
0:58 - Demo application walk-through
3:19 - Creating a base Class
5:53 - Making the base class abstract
8:44 - "Interface portion" in the abstract class. The blend of interface and base class
12:56 - Class inheritance in an abstract class
16:00 - When to use an abstract class
Рекомендации по теме
Комментарии
Автор

For clarity, this chap's tutorials are second to none. He takes a dry subject like 'abstract' classes, breaks it down, gives easy to follow examples and seems to enjoy conveying information to those less experienced than himself. Tim Corey deserves a cyber standing ovation.

signon
Автор

Hi Tim, I've been a lead for the past 12 years for 2 to 80 devs teams with tons of junior and mid level developers and I've never been able to explain in an easy and understandable way abstract classes, you nailed it my friend, from now on everytime a dev ask me to explain abstract classes to them I will send them a link to this video and demand from them to donate 5 bucks to your Patreon ;) Thank you man

rafaelg
Автор

Also for those that might be curious about the difference between a virtual method and an abstract method:
Virtual methods have an implementation and provide the derived classes with **the option** of overriding it.
while Abstract methods **do not** provide an implementation and **force** the derived classes to override the method.

amortalbeing
Автор

Oh my God !! 8 years after school, I for the first time, understand what is an abstract class. And the differences with an interface !

Thank you very much Monsieur Tim Corey

cirezno
Автор

A short video that absolutely nails it!

"A truck is not a car."

True... but a truck is a vehicle, and so is a car. So your base class would be vehicle and car and truck would be child classes since they have similar properties. A motorcycle is also a vehicle, as is a tractor. And all of them implement similar properties.

TheAngelOfDeath
Автор

I laughed out loud when auto generated subtitles said "a toilet on Tundra is not a car" at 17:52
great explanation btw, I think I understand all now

EnsYlmaz
Автор

Thank you for always explaining things in a calm and structured way!

louiseolsson
Автор

Thank you, Tim. If you find that I thank you more than once for the same video, it's because sometimes I watch the same video a lot of times :) (I wish I could learn only by watching the video once)

marceloleoncaceres
Автор

You're honestly the best Tim!! Your videos have helped me grasp the foundational topics so much, and I just love the way you explain concepts in such a clear and concise manner. Thanks loads!!!

isabelleseah
Автор

Thanks for this, I have been reading a book that is heavy on the how and light on the why/when. Your concise explanation helped me to understand the use cases for abstract classes better.

justinfs
Автор

Before this video I thought I understood what an abstract class is and how it works. Now I can certainly say I know way better than I used to. Thank you Tim! Awesome video!

kanteristu
Автор

Thank you for making this video. It absolutely helped me remove the fog in my mind and made it easy for me to explain Abstract Classes to my son.

daraiuskeeka
Автор

Wow you picked a great example to explain this. Also the explanations themselves are super understandable. In just 20 minutes you explained this way better than my teachers did in multiple lessons. It helped me a lot, thank you!!

Thomas-ixxq
Автор

I have taken many classes, and I can certainly say that you are very good at teaching. It is a pleasure to learn. I will certainly be purchasing classes.

marklord
Автор

I finally understood the use of abstract class !! Thanks for your great video

bernardbouree
Автор

Man, this is really great. I swear I have had so much trouble figuring out abstracts, delegates, and interfaces but these 3 videos changed that. I will be purchasing the full versions of your lessons and learning c# here from now on. I like to re write the code on my own to make sure I understand what each line is doing, and then trying to create my own examples after it helps it stick.

zachallen
Автор

Really good explanation for basic approaches. Good to have you here!

mantisk
Автор

This video was sufficient enough in the explanation in the sense that I can have that "Oh yeah, " moment while working. Thing is you have so many options to do the same thing and everyone will tell you something different on how to implement a solution. Sometimes you just need to be aware of a useful functionality.

louisswanepoel
Автор

thank you again for a simple explanation of something that seems complex

Shazbot
Автор

WOW! clear and concise the best explanation I have found of abstract classes

FranciscoPrado-rblu