C# static 🚫

Поделиться
HTML-код
  • Опубликовано: 2 июл 2021
  • 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!");
    }
    }
    }
  • НаукаНаука

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

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

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

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

  • @alianant
    @alianant Год назад +40

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

      9 months later where's your knowledge at :D

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

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

      @@ch1nc2yk39 bro what are you saying😂

  • @videolosss
    @videolosss Год назад +15

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

  • @WillyBGames
    @WillyBGames 6 месяцев назад +4

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

    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!

  • @EnglishVocabularyBooster
    @EnglishVocabularyBooster 10 месяцев назад +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.

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

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

  • @jaspidice3204
    @jaspidice3204 Год назад +30

    Awesome, you made this sound way more simpler compared to stackoverflow (:

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

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

  • @user-zb9ub5nd1z
    @user-zb9ub5nd1z 2 месяца назад

    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.

  • @yess.6558
    @yess.6558 10 месяцев назад

    Amazing explanation! All of your examples are really good!

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

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

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

    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.

  • @AlirezaR5
    @AlirezaR5 10 месяцев назад

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

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

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

    Your explanation is amazing! Thank you!!

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

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

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

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

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

    This was GREAT! Thank you

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

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

  • @Atom-Mercury
    @Atom-Mercury 7 месяцев назад

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

  • @jennerhecox
    @jennerhecox 6 месяцев назад

    Excellent explanation!

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

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

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

    AWESOME explanation!! Thank you!!

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

    Oh yeah, thanks for the video Bro.

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

    Awesome videos! Keep it up!

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

    Very clear explanation, thanks!

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

    What a great video. Thanks

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

    Bro, you explained this so well!

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

    This was so useful! Thanks man!

  • @enespinar9711
    @enespinar9711 6 месяцев назад +1

    Bro your explanation is superior

  • @JamesBond-jp6dp
    @JamesBond-jp6dp 7 месяцев назад

    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

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

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

  • @John_Macaroni
    @John_Macaroni 9 месяцев назад +1

    great tutorial

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

    Thanks so much!

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

    Thank you,and good vídeo

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

    Great that you write the code to your video .

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

    these tutorials are god_tier

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

    The definitions you use are up to the point🏹

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

    So easy to understand. thank you.

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

    Thank you bro!

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

    nice explanation bro

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

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

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

    Finally a good explanation

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

    very clear thank you!

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

    Concise and great.

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

    the best explanation thank you so much

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

    good explaination

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

    you are such a bro, bro.

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

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

  • @user-ig2os8gb6t
    @user-ig2os8gb6t 2 года назад

    nice explanation

  • @tbtmtfth
    @tbtmtfth 6 месяцев назад

    amazing

  •  2 года назад

    Thanks Bro!

  • @m16averick
    @m16averick 24 дня назад

    luv u bro

  • @ari-man
    @ari-man Год назад

    Thanks bruv

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

    thanks!

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

    Thank you

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

    Thanks

  • @Arctic.Wolves
    @Arctic.Wolves 9 месяцев назад

    Just for me to Refresh memory, thanks

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

    It was so clear

  • @user-pn4fs5wx7d
    @user-pn4fs5wx7d 2 года назад

    nice!

  • @6clix331
    @6clix331 Год назад

    this code bro guy is really cool

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

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

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

    noice

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

    brabo

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

    Yessss

  • @sbooontheroad
    @sbooontheroad 6 месяцев назад

    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 !

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

    i love u

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

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

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

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

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

      Super ​@@jorgeandrespalma2134

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

    bro do you like unity game engine development

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

    Bro please explain goto statement in cpp

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

    true American programmer🤣🤣

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

    lesson check😇

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

    :)

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

    Random comment years later

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

    the only bro we need is you not pewdiepie

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

    Random comnet

  • @baertbellemans7500
    @baertbellemans7500 6 месяцев назад

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

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

    Random comment

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

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

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

    A random comment down below

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

    Random comment down below

  • @user-up7kv5si4x
    @user-up7kv5si4x 10 месяцев назад

    random comment down below

  •  2 года назад

    Thanks Bro!