Abstract Class in C# and WHY you need to LEARN this

preview_player
Показать описание

Here are the links by the way!

This is going to be the first tutorial in a series of tutorials we are going to cover for all the keywords in C#!

So let's get started!

The first keyword that we will be covering is abstract

The `abstract` modifier indicates that the thing being modified has a missing or incomplete implementation.

The abstract modifier can be used with classes, methods, properties, indexers, and events.

For example, we can use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes, not instantiated on its own. Members marked as abstract must be implemented by non-abstract classes that derive from the abstract class.

Few things to note about abstract classes.

- An abstract class cannot be instantiated.
- It is not possible to modify an abstract class with the [sealed] Modifier.
Because the two modifiers have opposite meanings. The `sealed` modifier prevents a class from being inherited and the `abstract` modifier requires a class to be inherited.

There is more to know about abstract classes, of course, check out our C# Masterclass to learn more!

#cshart #programming #tutorial

tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.

Рекомендации по теме
Комментарии
Автор

yeah I have an interview coming in the new year so need this now more than ever 😁

divandebruin
Автор

This task was achievable by Interface as well while Abstract is the mixture of a base class and interface which was missing in the video. You can actually implement a method inside the Abstract class which is not allowed in an interface.

codeme
Автор

It's Nice to follow your tutorials.
Keep it up please.
Trying to make a turn based game with unity and I think that create an abstract class to implement basics fight potions for both player characters and enemies could save me a lot of times!

fulgencejuniorlohore
Автор

Just pointing out that while this tutorial is good for what it teaches you...
It's also incomplete and only teaches you HALF of what abstract classes can do.

It makes it seem like Interfaces and Abstract classes are the same thing, but they are in fact not.

Abstract classes allow you to implement methods, AND have methods that require being defined in whatever class that inherits it, where as interfaces you can not.

This difference is actually important to know, and can have a pretty big impact on your code structure.
This also means that abstract classes can inherit interfaces which if you only went off of what this tutorial teaches, you'd ask "Why would I want to do that?" but being able to combine the two can be really powerful.

vielassiel
Автор

Hey,
Why have You to add "using AbstractDemo", according to new template this namespace in Program.cs should be already added e?

lupo
Автор

Hey why isn't the Discord link on your website working? It says it's not valid. Awesome videos btw.

danielfrost
Автор

Which is the difference between inherits from abstract class and implements an interface, im so confused I feel that its the same thing

jesusserratoaguilar