Тёмный

C# static 🚫 

Bro Code
Подписаться 2,2 млн
Просмотров 74 тыс.
0% 0

C# static modifier tutorial example explained
#C# #static #modifier
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!");
}
}
}

Опубликовано:

 

13 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 106   
@BroCodez
@BroCodez 3 года назад
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!"); } } }
@ch1nc2yk39
@ch1nc2yk39 Год назад
My bro You're a G, thanks for the vid
@alianant
@alianant Год назад
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
@khajiit5556 Год назад
9 months later where's your knowledge at :D
@ch1nc2yk39
@ch1nc2yk39 Год назад
@@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?
@khajiit5556
@khajiit5556 Год назад
@@ch1nc2yk39 bro what are you saying😂
@videolosss
@videolosss 2 года назад
Best explanation of how we should use statics I have found.
@WillyBGames
@WillyBGames 10 месяцев назад
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.
@Bobreallywantsfriends
@Bobreallywantsfriends Год назад
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!
@nubnoobbo
@nubnoobbo 8 дней назад
<a href="#" class="seekto" data-time="112">1:52</a> I understood it right here. Wow that's cool.
@EnglishVocabularyBooster
@EnglishVocabularyBooster Год назад
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!
@tranielpride1362
@tranielpride1362 2 года назад
Bro thank you so much. THIS IS A HUGE HELP.
@soasertsus
@soasertsus 5 месяцев назад
Bro on god as a hobbyist programmer I have not understood what the fuck static is for for years and would just turn it on and off depending on if the compiler is yelling at me or not. And you just managed to explain exactly what it's for and when it would be necessary in under two minutes so clearly that I now perfectly understand when and how to use it. You're a god among men.
@Millequattro
@Millequattro Год назад
You are fantastic. Please never abandon us, keep on creating videos
@AmbrozeSE
@AmbrozeSE 7 месяцев назад
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.
@heek40
@heek40 5 месяцев назад
Went through like 5 videos explaining this topic and yours was the only one that made sense. Good stuff!
@alanciux
@alanciux Месяц назад
Extraordinary explanation. I should've starting watching your videos long time ago.
@enespinar9711
@enespinar9711 11 месяцев назад
Bro your explanation is superior
@lunaticberserker5869
@lunaticberserker5869 Год назад
He's truly a Chad when it comes to explaining stuff.
@FiR3Dr4g0n
@FiR3Dr4g0n 2 года назад
awesome tut!!! what's your vs theme btw?
@AlirezaR5
@AlirezaR5 Год назад
Thanks bro. Been following you since you had only 2k subscribers
@FunnySubmarine-ij4zk
@FunnySubmarine-ij4zk 7 месяцев назад
The definitions you use are up to the point🏹
@JamesBond-jp6dp
@JamesBond-jp6dp 11 месяцев назад
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
@ariwanabdollah6758
@ariwanabdollah6758 11 месяцев назад
Very nice explanation for someone who's learning C# :)
@anumamir9772
@anumamir9772 4 месяца назад
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".
@khoa4k266
@khoa4k266 7 месяцев назад
No one explained this easier than you bro. Thank you so much!
@MDBoss-fv2eu
@MDBoss-fv2eu 3 месяца назад
Thanks! Had a blue locke awakening watching this
@yess.6558
@yess.6558 Год назад
Amazing explanation! All of your examples are really good!
@spartanranger
@spartanranger 3 года назад
Oh yeah, thanks for the video Bro.
@shalev448
@shalev448 4 дня назад
thank you so much. why are you so good at explaining???
@devway5473
@devway5473 Год назад
Thank you i was trying to count within the class and could not figure it out this helps a ton!
@Atom-Mercury
@Atom-Mercury 11 месяцев назад
Best video about static i`ve watched. Thanks Bro.
@stra3947
@stra3947 3 года назад
Great that you write the code to your video .
@cimiur
@cimiur Месяц назад
clear and concise. thanks!
@the_3d_cookie
@the_3d_cookie 2 года назад
where have you been all my life These videos are so easy to understand Thanks Bro
@145Jamie
@145Jamie 9 месяцев назад
This was GREAT! Thank you
@thg1nrediar
@thg1nrediar 2 года назад
Thank you,and good vídeo
@simonroyjonesuk
@simonroyjonesuk Год назад
What a great video. Thanks
@iamnotapro869
@iamnotapro869 2 года назад
That was easy Love all of ur videos they answer the questionz that kept bothering me for so long . U earned a sub
@chile7743
@chile7743 Год назад
these tutorials are god_tier
@peternydahl6150
@peternydahl6150 Год назад
Wow, so well explained. Genius! 🙏🏻🙏🏻🙏🏻 Thanks a lot! :D
@John_Macaroni
@John_Macaroni Год назад
great tutorial
@mithraperera5980
@mithraperera5980 2 года назад
Your explanation is amazing! Thank you!!
@jennerhecox
@jennerhecox 10 месяцев назад
Excellent explanation!
@Not_ghale
@Not_ghale 2 месяца назад
Dude. thank you. Youre awesome
@Michael-sb1tt
@Michael-sb1tt 7 месяцев назад
Awesome videos! Keep it up!
@UmarAlFarooq
@UmarAlFarooq Год назад
AWESOME explanation!! Thank you!!
@aiueo8962
@aiueo8962 Год назад
That's great, now, I just know how to use static modifier, thanks..
@johnasblasco3564
@johnasblasco3564 9 месяцев назад
nice explanation bro
@ITGUY-b9u
@ITGUY-b9u Год назад
the best explanation thank you so much
@sweatermanny94
@sweatermanny94 2 года назад
Very clear explanation, thanks!
@user-xl5lc3qw5z
@user-xl5lc3qw5z 2 года назад
Finally a good explanation
@ahmedishmumrashique6285
@ahmedishmumrashique6285 2 года назад
good explaination
@thomaskojiabe7495
@thomaskojiabe7495 Год назад
So easy to understand. thank you.
@FullExtension1
@FullExtension1 Год назад
you are such a bro, bro.
@redheadrusskie
@redheadrusskie 2 года назад
Thanks so much!
@Phil-nc5mw
@Phil-nc5mw Год назад
Ive spent forever trying to understand why you would want to use static and it finally clicked.
@PolarGenre
@PolarGenre Год назад
Bro, you explained this so well!
@asafb1984
@asafb1984 Год назад
Concise and great.
@cookiecrumbzi
@cookiecrumbzi Год назад
Question: Is there any difference between using the static modifier vs the abstract modifier for a class?
@jorgeandrespalma2134
@jorgeandrespalma2134 Год назад
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.
@mounikanimma189
@mounikanimma189 9 месяцев назад
Super ​@@jorgeandrespalma2134
@Arctic.Wolves
@Arctic.Wolves Год назад
Just for me to Refresh memory, thanks
@SoulOfReagge
@SoulOfReagge Год назад
This was so useful! Thanks man!
@sbooontheroad
@sbooontheroad 10 месяцев назад
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 !
@tbtmtfth
@tbtmtfth 11 месяцев назад
amazing
@souleyedeme1902
@souleyedeme1902 Год назад
Thank you bro!
@黃祐宇
@黃祐宇 2 года назад
nice explanation
@boopfer387
@boopfer387 Год назад
very clear thank you!
@LuizHenrique-gm1cc
@LuizHenrique-gm1cc Год назад
Thanks
@asem8103
@asem8103 Месяц назад
perfect
@ubongsky1
@ubongsky1 8 месяцев назад
It was so clear
@cutecandygames1874
@cutecandygames1874 2 года назад
Thank you
@6clix331
@6clix331 Год назад
this code bro guy is really cool
@indiegamedevguy101
@indiegamedevguy101 2 месяца назад
make my brain turn mushyyyy goooooshieeeeieiei
@m16averick
@m16averick 5 месяцев назад
luv u bro
@thg1nrediar
@thg1nrediar 2 года назад
Yessss
3 года назад
Thanks Bro!
@ari-man
@ari-man 2 года назад
Thanks bruv
@MartynasCepauskas
@MartynasCepauskas 18 дней назад
what about private static methods ? any good ?
@LucParent905
@LucParent905 3 года назад
thanks!
@budderrar5751
@budderrar5751 Год назад
noice
@דניאלאלן
@דניאלאלן 2 года назад
nice!
@augischadiegils.5109
@augischadiegils.5109 3 года назад
@ProphetSac
@ProphetSac 2 года назад
i love u
@Overlordbr1
@Overlordbr1 2 года назад
brabo
@arunachalpradesh399
@arunachalpradesh399 2 года назад
bro do you like unity game engine development
@definitelynotchris4776
@definitelynotchris4776 13 дней назад
bzzz
@SaeedDoSomthing
@SaeedDoSomthing Год назад
true American programmer🤣🤣
@baertbellemans7500
@baertbellemans7500 11 месяцев назад
Except, a car class shouldn't be keeping track of the number of cars there are and when the race has started.
@indiegamedevguy101
@indiegamedevguy101 2 месяца назад
make my brain turn musshy gooooshiieiieei
@videoenjoyerthatlikesvidoes
@videoenjoyerthatlikesvidoes 11 месяцев назад
:)
@whitedinamo
@whitedinamo 2 года назад
lesson check😇
@aditya_asundi
@aditya_asundi 3 года назад
Bro please explain goto statement in cpp
@Ocer.
@Ocer. Год назад
Random comment years later
@fnarmusiccomposition3418
@fnarmusiccomposition3418 2 года назад
the only bro we need is you not pewdiepie
@Proviper666
@Proviper666 2 года назад
Random comnet
@pratyush_ngdgaikwad6563
@pratyush_ngdgaikwad6563 Год назад
meow (as you asked for a random comment) :)
@AlaaENG
@AlaaENG 2 месяца назад
Wuttt
@joaomarcosbastos9443
@joaomarcosbastos9443 Год назад
A random comment down below
@mohamedkunle528
@mohamedkunle528 2 года назад
Random comment
@the_dude_josh
@the_dude_josh 9 месяцев назад
Random comment down below
@chatGPT-ni7gx
@chatGPT-ni7gx 4 месяца назад
mong ad rep
3 года назад
Thanks Bro!
@БулатПочанов
@БулатПочанов Год назад
random comment down below
Далее
C# overloaded constructors 🍕
4:21
Просмотров 27 тыс.
C# generics ⁉️
5:33
Просмотров 77 тыс.
КТО БОИТСЯ КЛОУНОВ?? #shorts
00:20
Просмотров 521 тыс.
Getters & Setters | C# | Tutorial 28
12:09
Просмотров 193 тыс.
C++ vs Rust: which is faster?
21:15
Просмотров 398 тыс.
C# constructors 👷
5:44
Просмотров 83 тыс.
The Star Language that will outshine Rust? Gleam
10:33
how Google writes gorgeous C++
7:40
Просмотров 906 тыс.
The size of your variables matters.
11:03
Просмотров 123 тыс.