using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // static = modifier to declare a static member, which belongs to the class itself // rather than to any specific object Car car1 = new Car("Mustang"); Car car2 = new Car("Corvette"); Car car3 = new Car("Lambo"); Console.WriteLine(Car.numberOfCars); Car.StartRace(); Console.ReadKey(); } } class Car { String model; public static int numberOfCars; public Car(String model) { this.model = model; numberOfCars++; } public static void StartRace() { Console.WriteLine("The race has begun!"); } } }
I'm a beginner programmer. I feel like you have this innate ability to smash through all the knowledge that you have, and distill it all into what even a beginner can understand. It's so clear and concise. You just leave all that extra knowledge by the side and it keeps you from overexplaining. You're amazing.
@@khajiit5556 "Explain" doesn't mean the knowledge he poured into his student's head will stay there forever you get an explanation if u make use of it or not is up to you Oh and btw, if we use your logic to memories you have does it mean you didn't live through your early years or what?
I have been programming for years at a somewhat base level but I have had multiple people explain static to me and this video is the first time I've actually fully grasped the use of it and the power behind it. Thanks for the short but knowledge filled video.
I've been finding it pretty hard to understand concepts because every other resource i've used overexplains everything, you just make it clear and concise. I'm finally starting to understand, I didn't know I can learn the basics of static members in just 5 minutes. Thanks Bro Code!
Bro, you are a really brilliant teacher! For 10 years I have been struggling with this static thing. Now I understood it in 5 minutes. That is amazing!!! Thank you!
You should have seen me cheering up when you finally made this whole thing clear. Now I clearly understand what a static member means in a class. Thank you so much.
My college teacher just went through the comment bit explaining it but then didnt explain that whereas you have explained the explanation which i now understand, thanks
God bless u dude. i watched several videos some had weird Indian english, some just couldn't explain it in a way i could understand and some were both. 😒😒. finally understood what this static is. been coding for quite some time always tried my best to stay away from the word "static".
Yes. Abstract classes act as blueprints for other classes to inherit from while static classes serve as utility fixed classes. Quick example for static class: If you want to build a simple calculator, you can create a static class named Operations and have 4 static methods (add, subtract, division, multiply), each method will perform an operation with int a & b. To call it, simply put Operations.Add(1,2) in your main program. Other classes won't be able to modify the method and will not be able to create objects from this class. Quick example for abstract class: You want animals to make a sound. You will create an abstract class named Animals and create an abstract method MakeSound(), You're now preventing people from creating an object from Animal, which by itself is not an animal. Now you create a Dog class that inherits from Animal. Now you can override the MakeSound method to console write "bark". If you want to hear the bark, you need to create a Dog object and then call the method: class Dog : Animal Dog dog = new Dog(); dog.MakeSound(Console.WriteLine("Bark"); I hope this helps you or anyone else struggling to understand access modifiers. It's very important to know them well for professional success.
thanks for the video, really nice! I tried to use your code in Visual Studio and get error message: Compiler Error CS5001 " Program does not contain a static 'Main' method suitable for an entry point". Hence i cannot run it. Anything i can do to make it run and close this error message? Thanks !
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// static = modifier to declare a static member, which belongs to the class itself
// rather than to any specific object
Car car1 = new Car("Mustang");
Car car2 = new Car("Corvette");
Car car3 = new Car("Lambo");
Console.WriteLine(Car.numberOfCars);
Car.StartRace();
Console.ReadKey();
}
}
class Car
{
String model;
public static int numberOfCars;
public Car(String model)
{
this.model = model;
numberOfCars++;
}
public static void StartRace()
{
Console.WriteLine("The race has begun!");
}
}
}
My bro You're a G, thanks for the vid
I'm a beginner programmer. I feel like you have this innate ability to smash through all the knowledge that you have, and distill it all into what even a beginner can understand.
It's so clear and concise. You just leave all that extra knowledge by the side and it keeps you from overexplaining. You're amazing.
9 months later where's your knowledge at :D
@@khajiit5556 "Explain" doesn't mean the knowledge he poured into his student's head will stay there forever you get an explanation if u make use of it or not is up to you
Oh and btw, if we use your logic to memories you have does it mean you didn't live through your early years or what?
@@ch1nc2yk39 bro what are you saying😂
2 years, please tell me you've released a game ;-0
Best explanation of how we should use statics I have found.
I have been programming for years at a somewhat base level but I have had multiple people explain static to me and this video is the first time I've actually fully grasped the use of it and the power behind it. Thanks for the short but knowledge filled video.
I've been finding it pretty hard to understand concepts because every other resource i've used overexplains everything, you just make it clear and concise. I'm finally starting to understand, I didn't know I can learn the basics of static members in just 5 minutes. Thanks Bro Code!
Bro, you are a really brilliant teacher! For 10 years I have been struggling with this static thing. Now I understood it in 5 minutes. That is amazing!!! Thank you!
Bro thank you so much. THIS IS A HUGE HELP.
1:52 I understood it right here. Wow that's cool.
You are fantastic. Please never abandon us, keep on creating videos
You should have seen me cheering up when you finally made this whole thing clear. Now I clearly understand what a static member means in a class. Thank you so much.
Went through like 5 videos explaining this topic and yours was the only one that made sense. Good stuff!
Just started learning c# this is the best video i have seen to help explain static
1 month, you still going?
Bro your explanation is superior
This explanation blew my mind,
Thank you Bro Code.
Best Explanation that works for me.
No one explained this easier than you bro. Thank you so much!
Extraordinary explanation. I should've starting watching your videos long time ago.
Very nice explanation for someone who's learning C# :)
Thanks bro.
Been following you since you had only 2k subscribers
He's truly a Chad when it comes to explaining stuff.
My college teacher just went through the comment bit explaining it but then didnt explain that whereas you have explained the explanation which i now understand, thanks
Amazing explanation! All of your examples are really good!
where have you been all my life
These videos are so easy to understand
Thanks Bro
Oh yeah, thanks for the video Bro.
I just found your channel and I love every video,v best explanations on TH-cam
Best video about static i`ve watched. Thanks Bro.
Thank you i was trying to count within the class and could not figure it out this helps a ton!
God bless u dude. i watched several videos some had weird Indian english, some just couldn't explain it in a way i could understand and some were both. 😒😒. finally understood what this static is. been coding for quite some time always tried my best to stay away from the word "static".
That was easy
Love all of ur videos they answer the questionz that kept bothering me for so long . U earned a sub
Your explanation is amazing! Thank you!!
Thanks! Had a blue locke awakening watching this
Wow, so well explained. Genius! 🙏🏻🙏🏻🙏🏻 Thanks a lot! :D
Great that you write the code to your video .
The definitions you use are up to the point🏹
Thank you,and good vídeo
these tutorials are god_tier
Very clear explanation, thanks!
Excellent explanation!
AWESOME explanation!! Thank you!!
thank you so much.
why are you so good at explaining???
nice explanation
This was GREAT! Thank you
Such a good explanation
Bro, you explained this so well!
Finally a good explanation
great tutorial
This was so useful! Thanks man!
Awesome videos! Keep it up!
What a great video. Thanks
nicely explained
good explaination
clear and concise. thanks!
Thanks so much!
So easy to understand. thank you.
Dude. thank you. Youre awesome
nice explanation bro
the best explanation thank you so much
That's great, now, I just know how to use static modifier, thanks..
you are such a bro, bro.
You are awesome !
Concise and great.
very clear thank you!
awesome tut!!! what's your vs theme btw?
Ive spent forever trying to understand why you would want to use static and it finally clicked.
Thank you bro!
Question: Is there any difference between using the static modifier vs the abstract modifier for a class?
Yes. Abstract classes act as blueprints for other classes to inherit from while static classes serve as utility fixed classes.
Quick example for static class: If you want to build a simple calculator, you can create a static class named Operations and have 4 static methods (add, subtract, division, multiply), each method will perform an operation with int a & b. To call it, simply put Operations.Add(1,2) in your main program. Other classes won't be able to modify the method and will not be able to create objects from this class.
Quick example for abstract class: You want animals to make a sound. You will create an abstract class named Animals and create an abstract method MakeSound(), You're now preventing people from creating an object from Animal, which by itself is not an animal. Now you create a Dog class that inherits from Animal. Now you can override the MakeSound method to console write "bark". If you want to hear the bark, you need to create a Dog object and then call the method:
class Dog : Animal
Dog dog = new Dog();
dog.MakeSound(Console.WriteLine("Bark");
I hope this helps you or anyone else struggling to understand access modifiers. It's very important to know them well for professional success.
Super @@jorgeandrespalma2134
Just for me to Refresh memory, thanks
amazing
Thanks Bro!
Thank you
what about private static methods ? any good ?
this code bro guy is really cool
thanks!
luv u bro
the only bro we need is you not pewdiepie
thanks for the video, really nice! I tried to use your code in Visual Studio and get error message: Compiler Error CS5001 "
Program does not contain a static 'Main' method suitable for an entry point". Hence i cannot run it. Anything i can do to make it run and close this error message? Thanks !
Thanks bruv
nice!
perfect
Thanks
make my brain turn mushyyyy goooooshieeeeieiei
thanku bro
It was so clear
true American programmer🤣🤣
bro do you like unity game engine development
noice
Yessss
❤
brabo
bzzz
Bro please explain goto statement in cpp
make my brain turn musshy gooooshiieiieei
lesson check😇
i love u
Random comment years later
Except, a car class shouldn't be keeping track of the number of cars there are and when the race has started.
:)
meow (as you asked for a random comment) :)
A random comment down below
Random comnet
random comment down below