using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // interface = defines a "contract" that all the classes inheriting from should follow // An interface declares "what a class should have" // An inheriting class defines "how it should do it" // Benefit = security + multiple inheritance + "plug-and-play" Rabbit rabbit = new Rabbit(); Hawk hawk = new Hawk(); Fish fish = new Fish(); rabbit.Flee(); hawk.Hunt(); fish.Flee(); fish.Hunt(); Console.ReadKey(); } interface IPrey { void Flee(); } interface IPredator { void Hunt(); } class Rabbit : IPrey { public void Flee() { Console.WriteLine("The rabbit runs away!"); } } class Hawk : IPredator { public void Hunt() { Console.WriteLine("The hawk is searching for food!"); } } class Fish : IPrey, IPredator { public void Flee() { Console.WriteLine("The fish swims away!"); } public void Hunt() { Console.WriteLine("The fish is searching for smaller fish!"); } } } }
Zero BS, straight to the point. After watching your video I inmediately understood how to refactor my existing programs using Interfaces. Thank you very much!
getting into programing for game development as I have always been fascinated by it and your vids are the best I have found. You explain it in such a way that actually helps me learn. Most coding videos on UA-cam are so hard to listen to as they don't know how to communicate their skills properly. But I thank you for doing such a good job with it as your videos help me a lot.
This helped me so much I was so confused having to do this at my internship and I got the hang of it in 5 minutes because you explained this so well! Thank thank you
Great video thanks. I think thats the first time I understand what an interface does. Everyone keeps talking about contracts, but you are the first person to explain it in a way I can understand.
Bravo !!! Finally, someone’s demonstrated a concept without making the example so simple that you do not, first have to grapple your mind with the details of the example to understand the underlying concept. It is very rare to find an engineer who can communicate an idea concisely without confusing everyone. 👏👏👏
Spent a couple of years learning C# online through UA-cam videos, I learned alot to the point where I created a console program to make pizzas from scratch. The program I wrote allowed me to input keys to the console that allowed option selection. I learned that through Michael Hadley's Intro to Programming tutorials. However I struggled like a muddabucka with a few things to this day. Interfaces being one them. Today I am on Unity exploring real game design, and their lesson courses are amazing. All the C# know-how I learned proved worth it, because I am flying through the courses - because Unity's documentation doe alot of work for you. But there was a course that used IEnumerators in Unity. Sure I understood what the IEnumerator as for - but I still never understood Interfaces themselves. Now I do thanks to your video. And i's such a clear and easy concept i feel so dumb tonot have grasped them before. But thanks man! ... I mean... Bro.
I was so stuck on this topic, reading from a book and it wasnt overly clear, You my good sir gave me a eureka moment. Thank you so much, Liked and subed :)
Thank you very much. I'm from Brazil, and I know a litlle bit English, and these help me to understand what you were explaining, and the form how you were explaining was so simple, I could learn about the interfaces.
This seems extremely useful when making games and programs in general! Sometimes a class/object might be of another type as well, and need a certain method (etc.). This helps you to not forget to add the method. For example, in a survival game: Birds, cattle, humans, and fish are all organisms. They all need a method to "eat" to survive. If you forget to add a "eat" method, one of them might die of hunger with no way to keep them alive!
Thanks very clear. The multiple inheritance is good. But in my experience it seems most projects tend to have a one-to-one model where each class has an interface all to itself that is never implemented elsewhere, hence overkill.
I only know a little English and have a lot of difficulty listening to native speakers. Luckily, UA-cam has an automatic translation function :D I'm from Vietnam, the video is really useful.
It's pretty basic explanation. If you watch this video you won't really understand why you should use interfaces. Yet it's pretty good to introduce the topic
Good video. Just one point, a class is said to implement an interface and to inhererit from another class. Also, it would be good if you perhaps demonstrated why a dev may choose to use interfaces. E.g. polymorphism and dependency injection, for example.
Video clip explains how to implement C# interfaces but still doesn't give any insight as when it's best used. For example, could have been better explained that the Hawk sweeps into a shoal if fish within the sea, the shoal of fish is made up of many different types of fish, but all of the fish have an Eatable() method that is defined within the interface IPray, the Hawk doesn't care what type of fish it is, only that it has a Eatable() method. Or think in game terms, there are many types of enemy in the game such as Zombie, Witch, AxeMan. all those enemy's killable() method is exposed through a interface. So the player fires a burst of bullets and kills enemy via an interface to the killable() method. So using an interface if a far better way of using if else statments such as if(Zombie || Witch || AxeMan ) destroy().
I would like for you to please please expound on the "benefits" of using interfaces. Just seems like additional work. Why would I ever NEED to implement them? I've heard "dependency injection" but I'm still not able to wrap my mind around why would I spend extra time creating interfaces when I can just create the methods.
I wish learning programming was done with examples and a straight forward approach like this instead of hundreds of pages reading about nothing but confusion.
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// interface = defines a "contract" that all the classes inheriting from should follow
// An interface declares "what a class should have"
// An inheriting class defines "how it should do it"
// Benefit = security + multiple inheritance + "plug-and-play"
Rabbit rabbit = new Rabbit();
Hawk hawk = new Hawk();
Fish fish = new Fish();
rabbit.Flee();
hawk.Hunt();
fish.Flee();
fish.Hunt();
Console.ReadKey();
}
interface IPrey
{
void Flee();
}
interface IPredator
{
void Hunt();
}
class Rabbit : IPrey
{
public void Flee()
{
Console.WriteLine("The rabbit runs away!");
}
}
class Hawk : IPredator
{
public void Hunt()
{
Console.WriteLine("The hawk is searching for food!");
}
}
class Fish : IPrey, IPredator
{
public void Flee()
{
Console.WriteLine("The fish swims away!");
}
public void Hunt()
{
Console.WriteLine("The fish is searching for smaller fish!");
}
}
}
}
OMG, You are Amazing..
? ing - isn't a verb! Algiers racism - kidnap ID!
Interface declares: "What a class should have"
An inheriting class defines: "How it should do it"
Chef's kiss of an explanation, thanks sir
I have seen other videos, and this is the best explanation i've seen so far. Thanks a lot. I've subscribed.
Your explanations are one of the clearest and easiest to remember ones I've ever come across. Great job!
My teacher has spent hours confusing this for me. This was so clear
Teachers are so dumb nowadays
well, it is a bit more complicated than that. We can create a class object by using an interface and criss cross stuff. It becomes a bit complicated
adam ol aklını alırım
Wow you have teacher , interesting 😁
@@MFLBilisim o cikis niye amk haahahaha yoksa o adamin ögretmeni senmisin?
Zero BS, straight to the point. After watching your video I inmediately understood how to refactor my existing programs using Interfaces. Thank you very much!
getting into programing for game development as I have always been fascinated by it and your vids are the best I have found. You explain it in such a way that actually helps me learn. Most coding videos on UA-cam are so hard to listen to as they don't know how to communicate their skills properly. But I thank you for doing such a good job with it as your videos help me a lot.
Your ability to explain such complicated things so simply is simply amazing to me.
Thank you for a great channel and quality content!
After years, your tutorials still the best
IPrey for you 🙏
This helped me so much I was so confused having to do this at my internship and I got the hang of it in 5 minutes because you explained this so well! Thank thank you
I have spent YEARS trying to understand this. today, i fully understood this in 5 minutes . WOW
In an hour i'm writing an exam based on this. 10 minutes ago I knew shit about interfaces, now I know all I need. Huge thanks goes to this man! 🙏🏿
After days of studying and going through lecture material on this topic, I was still clueless until your 5' tutorial came to the rescue. 🙏
Most simple explanation I have seen on interfaces. Thank you!
My guy just made an intermediate programming concept seem look like a beginner programming concept. Thank you Mr.Chad.
Great video thanks. I think thats the first time I understand what an interface does. Everyone keeps talking about contracts, but you are the first person to explain it in a way I can understand.
Bravo !!! Finally, someone’s demonstrated a concept without making the example so simple that you do not, first have to grapple your mind with the details of the example to understand the underlying concept. It is very rare to find an engineer who can communicate an idea concisely without confusing everyone. 👏👏👏
Spent a couple of years learning C# online through UA-cam videos, I learned alot to the point where I created a console program to make pizzas from scratch. The program I wrote allowed me to input keys to the console that allowed option selection. I learned that through Michael Hadley's Intro to Programming tutorials.
However I struggled like a muddabucka with a few things to this day. Interfaces being one them. Today I am on Unity exploring real game design, and their lesson courses are amazing. All the C# know-how I learned proved worth it, because I am flying through the courses - because Unity's documentation doe alot of work for you. But there was a course that used IEnumerators in Unity.
Sure I understood what the IEnumerator as for - but I still never understood Interfaces themselves. Now I do thanks to your video. And i's such a clear and easy concept i feel so dumb tonot have grasped them before.
But thanks man! ... I mean... Bro.
God bless people like you who distill this information down to what is necessary without waffling on.
2:16 Rabbit... rabbit... equals new... Rabbit. Made me lol. Excellent video.
Dude this is one of the best explanations of the interface of c#
Fantastic explanation and example. It was very clear and understandable!
in just 5 min whole concept is clear...thanks a lot..
Seeing video examples is so much better than seeing it being described in text for me
I was so stuck on this topic, reading from a book and it wasnt overly clear, You my good sir gave me a eureka moment. Thank you so much, Liked and subed :)
Thank you very much. I'm from Brazil, and I know a litlle bit English, and these help me to understand what you were explaining, and the form how you were explaining was so simple, I could learn about the interfaces.
Great explanation and cliff notes
Thanks for making the video so short and to the point
With a real practical example and less theory
WOW, Amazing... i was Struggling for 3 Months. Today i Got the ReaL idea. Thank You So Much
0:46
Me: Learning
My mind: Hawk tuah
...
Great! Saved me alot of time which i was wasting on reading nonscense books!! Now i know what are Interfaces!!!!❤
Best explanation of interfaces i've seen, thankyou :)
This guy explained in 5 mins what my lecturer took 50 for lmao
Better than the book I read. Thanks for a clear explanation.
This seems extremely useful when making games and programs in general! Sometimes a class/object might be of another type as well, and need a certain method (etc.). This helps you to not forget to add the method.
For example, in a survival game:
Birds, cattle, humans, and fish are all organisms. They all need a method to "eat" to survive. If you forget to add a "eat" method, one of them might die of hunger with no way to keep them alive!
Best tutorials! So well planned and pedagogical!
Best explanation about interfaces. Thanks a lot. I have subscribed.
I am starting to love your videos... They are short, precise... AND VERY EASY TO UNDERSTAND THE WAY YOUUUU EXPLAIN IT!!! Keep the great work BRO...
Very easy to understand.. Thanks bro
Supreme simplicity, sir.
This was a clear explanation with great examples. Thank you!
Was struggling with understanding this thanks for the clear explanation and solid examples :)
best explanation with simple example
Very well explained! Thanks!
that's almost the half part of one of my finals, Thank you
Excellent explanation...
Bro code you are the best. Keep it up bro
Soldaat!
perfect and compact explanation, thanks
Thanks, this was a really good approach to explaining the concept.
A++ Explaination. Helped a lot.
This was amazing
Really good video!
This code example helped me a lot to understand interfaces, thanks!
this channel is a fucking goldmine. summarises my 1hr lecture into 5mins.
Excellent simple and undrestandable video for beginners or even intermidiate programmers!
Please do a video on Abtract classes vs Interface Classes.
Thanks very clear. The multiple inheritance is good. But in my experience it seems most projects tend to have a one-to-one model where each class has an interface all to itself that is never implemented elsewhere, hence overkill.
great vid
Great basic explanation. Thank you!
Quick and simple. Great job!
Amazing u r a pro🤩
I only know a little English and have a lot of difficulty listening to native speakers. Luckily, UA-cam has an automatic translation function :D I'm from Vietnam, the video is really useful.
excellent
This topic is very weird and this is a very good explanaition, thank you!
Good explenation
It's pretty basic explanation. If you watch this video you won't really understand why you should use interfaces. Yet it's pretty good to introduce the topic
I finally understand interfaces now. Thanks!
your vids are so helpful
thank you so much! a concise and clear explanation!
nice video
Good video. Just one point, a class is said to implement an interface and to inhererit from another class. Also, it would be good if you perhaps demonstrated why a dev may choose to use interfaces. E.g. polymorphism and dependency injection, for example.
thank you for explaining this :)
Just gained a sub for such a clear explanation!
Good video. Thank you.
Simple but great explanation!
Thank you.
Not a bro but showing support. Thanks for the vid.
Great explanation - thank you!
Tq Dude for explaining in simple way
clear and concise. thanks!
Very helpful. Thank you!
bro!!!! - awesome
Killed it
"The world isn't perfect. But it's there for us, doing the best it can....that's what makes it so damn beautiful" - Roy Mustang
chad bro saved me thanks man gg
you're one of a kind!
it's clear now think you so much
Thanks bro. This was the missing link in my game project.
You are such a bro, bro.
Thanks..Very helpful.
Thanks man now I can be a brogrammer
Video clip explains how to implement C# interfaces but still doesn't give any insight as when it's best used. For example, could have been better explained that the Hawk sweeps into a shoal if fish within the sea, the shoal of fish is made up of many different types of fish, but all of the fish have an Eatable() method that is defined within the interface IPray, the Hawk doesn't care what type of fish it is, only that it has a Eatable() method. Or think in game terms, there are many types of enemy in the game such as Zombie, Witch, AxeMan. all those enemy's killable() method is exposed through a interface. So the player fires a burst of bullets and kills enemy via an interface to the killable() method. So using an interface if a far better way of using if else statments such as if(Zombie || Witch || AxeMan ) destroy().
Wow. Usually people need more than one video to win a sub from me, but you got it in just one!
I would like for you to please please expound on the "benefits" of using interfaces. Just seems like additional work. Why would I ever NEED to implement them? I've heard "dependency injection" but I'm still not able to wrap my mind around why would I spend extra time creating interfaces when I can just create the methods.
Amazing bro, thanks
I wish learning programming was done with examples and a straight forward approach like this instead of hundreds of pages reading about nothing but confusion.
Simple clear fast.
THANKS +1 SUBSCRIBER
Thanks for the video Bro.
best best best
Damm, I couldn't understand what that is for months in my uni, and I suddenly understand it in 5 min after finding this viedo
You truly are a bro