C# static 🚫

Поделиться
HTML-код
  • Опубликовано: 7 янв 2025

Комментарии • 114

  • @BroCodez
    @BroCodez  3 года назад +25

    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 Год назад +1

      My bro You're a G, thanks for the vid

  • @alianant
    @alianant 2 года назад +58

    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 Год назад +2

      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 Год назад +6

      @@ch1nc2yk39 bro what are you saying😂

    • @it41148
      @it41148 13 дней назад

      2 years, please tell me you've released a game ;-0

  • @DamnTimCan
    @DamnTimCan 2 года назад +23

    Best explanation of how we should use statics I have found.

  • @WillyBGames
    @WillyBGames Год назад +8

    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 Год назад +5

    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 3 месяца назад +3

    1:52 I understood it right here. Wow that's cool.

  • @EnglishVocabularyBooster
    @EnglishVocabularyBooster Год назад +3

    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 года назад +18

    Bro thank you so much. THIS IS A HUGE HELP.

  • @AmbrozeSE
    @AmbrozeSE 9 месяцев назад

    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.

  • @Millequattro
    @Millequattro 2 года назад +2

    You are fantastic. Please never abandon us, keep on creating videos

  • @zacharypaulino2023
    @zacharypaulino2023 Месяц назад

    Just started learning c# this is the best video i have seen to help explain static

    • @it41148
      @it41148 13 дней назад +1

      1 month, you still going?

  • @heek40
    @heek40 8 месяцев назад

    Went through like 5 videos explaining this topic and yours was the only one that made sense. Good stuff!

  • @YavorHadziev
    @YavorHadziev 8 дней назад

    Great explanation and examples! Thank you!

  • @enespinar9711
    @enespinar9711 Год назад +1

    Bro your explanation is superior

  • @surrealista06
    @surrealista06 3 месяца назад

    Extraordinary explanation. I should've starting watching your videos long time ago.

  • @ariwanabdollah6758
    @ariwanabdollah6758 Год назад

    Very nice explanation for someone who's learning C# :)

  • @khoa4k266
    @khoa4k266 9 месяцев назад

    No one explained this easier than you bro. Thank you so much!

  • @alcanyantelcontar6957
    @alcanyantelcontar6957 8 дней назад

    I just found your channel and I love every video,v best explanations on RUclips

  • @lunaticberserker5869
    @lunaticberserker5869 2 года назад +1

    He's truly a Chad when it comes to explaining stuff.

  • @JamesBond-jp6dp
    @JamesBond-jp6dp Год назад

    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

  • @spartanranger
    @spartanranger 3 года назад +3

    Oh yeah, thanks for the video Bro.

  • @anumamir9772
    @anumamir9772 7 месяцев назад

    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".

  • @FunnySubmarine-ij4zk
    @FunnySubmarine-ij4zk 10 месяцев назад

    The definitions you use are up to the point🏹

  • @yess.6558
    @yess.6558 Год назад

    Amazing explanation! All of your examples are really good!

  • @Atom-Mercury
    @Atom-Mercury Год назад

    Best video about static i`ve watched. Thanks Bro.

  • @AlirezaR5
    @AlirezaR5 Год назад

    Thanks bro.
    Been following you since you had only 2k subscribers

  • @MDBoss-fv2eu
    @MDBoss-fv2eu 6 месяцев назад

    Thanks! Had a blue locke awakening watching this

  • @the_3d_cookie
    @the_3d_cookie 2 года назад

    where have you been all my life
    These videos are so easy to understand
    Thanks Bro

  • @devway5473
    @devway5473 Год назад

    Thank you i was trying to count within the class and could not figure it out this helps a ton!

  • @stra3947
    @stra3947 3 года назад +2

    Great that you write the code to your video .

  • @peternydahl6150
    @peternydahl6150 Год назад

    Wow, so well explained. Genius! 🙏🏻🙏🏻🙏🏻 Thanks a lot! :D

  • @shalev448
    @shalev448 2 месяца назад

    thank you so much.
    why are you so good at explaining???

  • @chile7743
    @chile7743 Год назад

    these tutorials are god_tier

  • @mithraperera5980
    @mithraperera5980 2 года назад

    Your explanation is amazing! Thank you!!

  • @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

  • @thg1nrediar
    @thg1nrediar 2 года назад +2

    Thank you,and good vídeo

  • @145Jamie
    @145Jamie Год назад

    This was GREAT! Thank you

  • @cimiur
    @cimiur 4 месяца назад

    clear and concise. thanks!

  • @sweatermanny94
    @sweatermanny94 2 года назад

    Very clear explanation, thanks!

  • @UmarAlFarooq
    @UmarAlFarooq 2 года назад

    AWESOME explanation!! Thank you!!

  • @simonroyjonesuk
    @simonroyjonesuk Год назад

    What a great video. Thanks

  • @PolarGenre
    @PolarGenre 2 года назад

    Bro, you explained this so well!

  • @Michael-sb1tt
    @Michael-sb1tt 10 месяцев назад

    Awesome videos! Keep it up!

  • @jennerhecox
    @jennerhecox Год назад

    Excellent explanation!

  • @Notghale
    @Notghale 5 месяцев назад

    Dude. thank you. Youre awesome

  • @user-xl5lc3qw5z
    @user-xl5lc3qw5z 2 года назад +1

    Finally a good explanation

  • @aiueo8962
    @aiueo8962 Год назад

    That's great, now, I just know how to use static modifier, thanks..

  • @thomaskojiabe7495
    @thomaskojiabe7495 2 года назад

    So easy to understand. thank you.

  • @John_Macaroni
    @John_Macaroni Год назад +1

    great tutorial

  • @SoulOfReagge
    @SoulOfReagge Год назад

    This was so useful! Thanks man!

  • @szyszak3338
    @szyszak3338 Месяц назад

    nicely explained

  • @redheadrusskie
    @redheadrusskie 3 года назад +1

    Thanks so much!

  • @ITGUY-b9u
    @ITGUY-b9u 2 года назад

    the best explanation thank you so much

  • @armoirestudio
    @armoirestudio 14 дней назад

    You are awesome !

  • @FullExtension1
    @FullExtension1 2 года назад

    you are such a bro, bro.

  • @johnasblasco3564
    @johnasblasco3564 11 месяцев назад

    nice explanation bro

  • @Phil-nc5mw
    @Phil-nc5mw Год назад

    Ive spent forever trying to understand why you would want to use static and it finally clicked.

  • @asafb1984
    @asafb1984 2 года назад

    Concise and great.

  • @FiR3Dr4g0n
    @FiR3Dr4g0n 2 года назад +1

    awesome tut!!! what's your vs theme btw?

  • @黃祐宇
    @黃祐宇 3 года назад

    nice explanation

  • @ahmedishmumrashique6285
    @ahmedishmumrashique6285 2 года назад

    good explaination

  • @boopfer387
    @boopfer387 2 года назад

    very clear thank you!

  • @Arctic.Wolves
    @Arctic.Wolves Год назад

    Just for me to Refresh memory, thanks

  • @souleyedeme1902
    @souleyedeme1902 Год назад

    Thank you bro!

  • @6clix331
    @6clix331 2 года назад

    this code bro guy is really cool

  • @cookiecrumbzi
    @cookiecrumbzi Год назад +2

    Question: Is there any difference between using the static modifier vs the abstract modifier for a class?

    • @jorgeandrespalma2134
      @jorgeandrespalma2134 Год назад +4

      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 11 месяцев назад

      Super ​@@jorgeandrespalma2134

  • @tbtmtfth
    @tbtmtfth Год назад

    amazing

  •  3 года назад

    Thanks Bro!

  • @indiegamedevguy101
    @indiegamedevguy101 5 месяцев назад

    make my brain turn mushyyyy goooooshieeeeieiei

  • @cutecandygames1874
    @cutecandygames1874 2 года назад

    Thank you

  • @asem8103
    @asem8103 3 месяца назад

    perfect

  • @LuizHenrique-gm1cc
    @LuizHenrique-gm1cc Год назад

    Thanks

  • @m16averick
    @m16averick 7 месяцев назад

    luv u bro

  • @ari-man
    @ari-man 2 года назад

    Thanks bruv

  • @numa8202
    @numa8202 Месяц назад

    thanku bro

  • @LucParent905
    @LucParent905 3 года назад

    thanks!

  • @דניאלאלן
    @דניאלאלן 3 года назад

    nice!

  • @ubongsky1
    @ubongsky1 11 месяцев назад

    It was so clear

  • @SaeedDoSomthing
    @SaeedDoSomthing Год назад

    true American programmer🤣🤣

  • @thg1nrediar
    @thg1nrediar 2 года назад

    Yessss

  • @MartynasCepauskas
    @MartynasCepauskas 3 месяца назад

    what about private static methods ? any good ?

  • @budderrar5751
    @budderrar5751 2 года назад

    noice

  • @indiegamedevguy101
    @indiegamedevguy101 5 месяцев назад

    make my brain turn musshy gooooshiieiieei

  • @whitedinamo
    @whitedinamo 2 года назад

    lesson check😇

  • @sbooontheroad
    @sbooontheroad Год назад

    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 !

  • @Overlordbr1
    @Overlordbr1 2 года назад

    brabo

  • @augischadiegils.5109
    @augischadiegils.5109 3 года назад

  • @ProphetSac
    @ProphetSac 2 года назад

    i love u

  • @Ocer.
    @Ocer. Год назад

    Random comment years later

  • @definitelynotchris4776
    @definitelynotchris4776 3 месяца назад

    bzzz

  • @fnarmusiccomposition3418
    @fnarmusiccomposition3418 2 года назад

    the only bro we need is you not pewdiepie

  • @baertbellemans7500
    @baertbellemans7500 Год назад

    Except, a car class shouldn't be keeping track of the number of cars there are and when the race has started.

  • @aditya_asundi
    @aditya_asundi 3 года назад

    Bro please explain goto statement in cpp

  • @arunachalpradesh399
    @arunachalpradesh399 2 года назад

    bro do you like unity game engine development

  • @pratyush_ngdgaikwad6563
    @pratyush_ngdgaikwad6563 Год назад

    meow (as you asked for a random comment) :)

  • @joaomarcosbastos9443
    @joaomarcosbastos9443 Год назад

    A random comment down below

  • @videoenjoyerthatlikesvidoes
    @videoenjoyerthatlikesvidoes Год назад

    :)

  • @Proviper666
    @Proviper666 2 года назад

    Random comnet

  • @БулатПочанов
    @БулатПочанов Год назад

    random comment down below

  • @AlaaENG
    @AlaaENG 4 месяца назад

    Wuttt