using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // constructor = A special method in a class // Same name as the class name // Can be used to assign arguments to fields when creating an object Car car1 = new Car("Ford", "Mustang", 2022, "red"); Car car2 = new Car("Chevy", "Corvette", 2021, "blue"); car1.Drive(); car2.Drive(); Console.ReadKey(); } } class Car { String make; String model; int year; String color; public Car(String make, String model, int year, String color) { this.make = make; this.model = model; this.year = year; this.color = color; } public void Drive() { Console.WriteLine("You drive the " + make + " " + model); } } }
Hey Bro Code, please, keep doing this type of videos: Short, concise and straight to the point. Those are good for the ones that already have some knowledge and just want a refresher or do not like to wait a lot. I love it! Thanks!
Bro you are by far the best at explaining basic concepts on youtube for C# that I've watched. Everyone else bombarders beginners with jargon and is way less concise. Keep up the great work!
your examples are very simple and unique, but can you make a similar video with : an array of cars, private model - year ... , and using the constructor.
great video👍. P.S. try to differentiate the names of declared variables and parameters of the constructor. Like, "int year;" and "public Car(int aYear/carYear...) {}"
In Visual Studio you can use "ctor" and double tab then it will create constructor for you. Make sure the cursor inside the class. Reply if it works. Idk about versions. It's working in VS 2019.
Why are you using a capital S instead of s when writing string. Is there any difference? And why do you then use lowered case i for int instead of Int?
hi bro . umm just to let you know i dont know which language version your using but yeah i type the same code you show in your videos, for you ,you have no errors but i am running into many errors like object refrence is required for non static bla blah. btw i use vs code 2022..... please reply✌
Question : How to have default parameters and optional parameters ? for example : using the Car Class Make : default = "Bro", Model : default = "Punk" Year : default = 2048 Color : default = "black" then in the main I have : Car car3 = new Car(,"Woohoo",2023,) //expecting to have a Bro Woohoo which is made in 2023 and it's black ?
I think its the same concept to add default values to a variable, instead of String make; you would change this to “String make = “default;” that way if a field is left unassigned the program will automatically assign it that default value.
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// constructor = A special method in a class
// Same name as the class name
// Can be used to assign arguments to fields when creating an object
Car car1 = new Car("Ford", "Mustang", 2022, "red");
Car car2 = new Car("Chevy", "Corvette", 2021, "blue");
car1.Drive();
car2.Drive();
Console.ReadKey();
}
}
class Car
{
String make;
String model;
int year;
String color;
public Car(String make, String model, int year, String color)
{
this.make = make;
this.model = model;
this.year = year;
this.color = color;
}
public void Drive()
{
Console.WriteLine("You drive the " + make + " " + model);
}
}
}
Can you change the constructor parameter names so that they don't match the parameters at the top?
giving fast, effective lessons, and even leaves the code in comments
Truly a gigachad
Bro is defining of Gigachad
Hey Bro Code, please, keep doing this type of videos: Short, concise and straight to the point. Those are good for the ones that already have some knowledge and just want a refresher or do not like to wait a lot. I love it! Thanks!
You can really tell the effort put into a tutorial when it’s concise, easy to follow, and informative at the same time. Shits not easy. Good job
Bro you are by far the best at explaining basic concepts on youtube for C# that I've watched. Everyone else bombarders beginners with jargon and is way less concise. Keep up the great work!
the car example was exactly the explanation I was looking for. Thanks
I am new to programming, and your videos are the best as they are short, concise and use analogies. Keep up the good work.
Simply awesome. You're very good at this. Thank you. I watched the video once and I totally get it and ready to use it in my game.
85 views only! your supremely underrated
Not anymore 😊
Now it's increased
55k now
His channel has grown so much
77k now💀💀
Really appreciate your stuff, man! Saving my ass this finals season. Love what you do, keep keeping young people in coding.
Great delivery of the information! Really helps!
Bro, I really like your video. It is short, concise, and to the point. I wish you could make a series like that for C#
I struggle so much with my Codeacademy tutorials. You help me out. Beciming a bro soon
its so good and clear explain only five minutes
Random comment.// Great clear series, very informational.
good video.
Great!!!✌
Thank you! You helped me so much with studying c#, your channel is amazing! Also, your voice is so similar to Ryukahr's voice it's crazy!
Gigachad bro thx :))) sometimes i forget this little things xdxd and then ur videos can save me from troubles
Great!
Easy and simple
your examples are very simple and unique,
but can you make a similar video with : an array of cars, private model - year ... , and using the constructor.
great video👍. P.S. try to differentiate the names of declared variables and parameters of the constructor.
Like, "int year;" and "public Car(int aYear/carYear...) {}"
In Visual Studio you can use "ctor" and double tab then it will create constructor for you. Make sure the cursor inside the class. Reply if it works. Idk about versions. It's working in VS 2019.
Wow!
Bro I finally understand 🙏🙏🙏
"hey dad, why did you name me Bro Code"
-my future daughter
👌👌
You're actually the goat
Thanks for the video Bro.
great vid👍🏻
God Job
I love cars that makes vroom vroom sound
Merci M. Bro
Why are you using a capital S instead of s when writing string. Is there any difference? And why do you then use lowered case i for int instead of Int?
thank you
The Time to Subscribe, TTS, is under 45 seconds.
Legend.
thank you so much
❤
If it has all four tires and gets you from point A to point B then it's a car" - Takumi Fujiwara
Pew pew pow
thx Bro ...
noice
Thanks Bro!
hi bro . umm just to let you know i dont know which language version your using but yeah i type the same code you show in your videos, for you ,you have no errors but i am running into many errors like object refrence is required for non static bla blah. btw i use vs code 2022..... please reply✌
Großartig!!
for Car, why the year is not passed on the Drive method? Nor the color
TY
👍
Watching in 2024
Sir your voice is very clear but the screen is not clear
How come you named the constructor also Human (same name as the class 'Human' declaration)? Is that a requirement or just convention
why did you the same thing 2 times, only with different names.
We got it in the first example already.
good one
is it me or when you say like in the video the like and dislike button around it glows
Question :
How to have default parameters and optional parameters ?
for example : using the Car Class
Make : default = "Bro",
Model : default = "Punk"
Year : default = 2048
Color : default = "black"
then in the main I have :
Car car3 = new Car(,"Woohoo",2023,) //expecting to have a Bro Woohoo which is made in 2023 and it's black ?
I think its the same concept to add default values to a variable, instead of String make; you would change this to “String make = “default;” that way if a field is left unassigned the program will automatically assign it that default value.
lesson check😇
no need of this keyword in class constructor. Do we?
random comment🎉
u forgot to add the year xD
first
🤣🤣🤣🤣🤣🤣
brother, this is too complicated I dumb asf
Random comment down below
81k is still too little
random comment.
Comment
random comment
Random
second lol
random comment
Random
random comment