C# static 🚫

preview_player
Показать описание
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");

Car.StartRace();

Console.ReadKey();
}
}
class Car
{
String model;
public static int numberOfCars;

public Car(String model)
{
numberOfCars++;
}

public static void StartRace()
{
Console.WriteLine("The race has begun!");
}
}
}
Рекомендации по теме
Комментарии
Автор

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");


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!");
}
}
}

BroCodez
Автор

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.

alianant
Автор

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

videolosss
Автор

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.

WillyBGames
Автор

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!

Bobreallywantsfriends
Автор

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

tranielpride
Автор

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.

soasertsus
Автор

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!

EnglishVocabularyBooster
Автор

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.

zbubndz
Автор

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

Millequattro
Автор

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

heek
Автор

Thanks! Had a blue locke awakening watching this

MDBoss-fveu
Автор

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

anumamir
Автор

The definitions you use are up to the point🏹

FunnySubmarine-ijzk
Автор

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

lunaticberserker
Автор

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

khoak
Автор

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

JamesBond-jpdp
Автор

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

ariwanabdollah
Автор

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

AlirezaR
Автор

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

devway