C# objects 🧍‍♂️

  Рет қаралды 48,407

Bro Code

Bro Code

Күн бұрын

C# object oriented programming tutorial example explained
#C# #objects #classes
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// object = An instance of a class
// A class can be used as a blueprint to create objects (OOP)
// objects can have fields & methods (characteristics & actions)
Human human1 = new Human();
Human human2 = new Human();
human1.name = "Rick";
human1.age = 65;
human2.name = "Morty";
human2.age = 16;
human1.Eat();
human1.Sleep();
human2.Eat();
human2.Sleep();
Console.ReadKey();
}
}
class Human
{
public String name;
public int age;
public void Eat()
{
Console.WriteLine(name + " is eating");
}
public void Sleep()
{
Console.WriteLine(name + " is sleeping");
}
}
}

Пікірлер: 91
@BroCodez
@BroCodez 3 жыл бұрын
using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // object = An instance of a class // A class can be used as a blueprint to create objects (OOP) // objects can have fields & methods (characteristics & actions) Human human1 = new Human(); Human human2 = new Human(); human1.name = "Rick"; human1.age = 65; human2.name = "Morty"; human2.age = 16; human1.Eat(); human1.Sleep(); human2.Eat(); human2.Sleep(); Console.ReadKey(); } } class Human { public String name; public int age; public void Eat() { Console.WriteLine(name + " is eating"); } public void Sleep() { Console.WriteLine(name + " is sleeping"); } } }
@BananaMan6763
@BananaMan6763 5 ай бұрын
Radical!
@hingsing1
@hingsing1 4 ай бұрын
Thanks for pasting the code as well. Question- How come when you create the 'name' field within the Human class, the String has 'S' capitalized? I guess I'll find out later
@aarongarcia3296
@aarongarcia3296 Жыл бұрын
Awesome stuff! I’m learning C# through a book called C# players guide. It’s a very good book but your content is really solidifying some of the complex key terms
@ino1023
@ino1023 Жыл бұрын
Omg you're awesome! I struggled with OOP for 2 weeks in class and you just made this so simple. Thank you!
@ashrafsiddiq968
@ashrafsiddiq968 6 ай бұрын
I couldn't agree more
@stapelton21
@stapelton21 Жыл бұрын
@Bro, Your Teaching skills and the examples you use are phenomenal. I've learned from nothing to something, All thanks to these tutorials.
@abraham.hayden
@abraham.hayden 8 күн бұрын
Great video! Very easy to grasp and is easy to understand the concepts of a class. Appreciate this!
@victorh.lopezchavez4229
@victorh.lopezchavez4229 Жыл бұрын
Nice video bro!! you help to understand in a good way how objects works!!
@andrehufschmid
@andrehufschmid Жыл бұрын
Perfect. Very well explained with a good example.
@liamspruyt
@liamspruyt 4 күн бұрын
simple but effective teaching!
@orpheuscreativeco9236
@orpheuscreativeco9236 7 ай бұрын
Very straightforward and relatable 👍
@osplace3309
@osplace3309 Жыл бұрын
Bro you are the best im trying to understand what is object for hours and you just made it clear, thak you so much!
@aziz-mv7qo
@aziz-mv7qo 2 жыл бұрын
wubba lubba dub dub!
@PixelPickleWaffle
@PixelPickleWaffle 4 ай бұрын
Jhinga lala hoo hoo
@itsashhuby6781
@itsashhuby6781 Жыл бұрын
You explained this so well thank you!
@alexandregb566
@alexandregb566 Жыл бұрын
Evereyone's first project: "Hello world" My first project: Creating a human being from scratch
@willlywillly
@willlywillly Жыл бұрын
Bro are awesome. Been trying to figure OOP thinking it's rocket science but you have made it where even I can understand it. Actually I got a degree in rocket science but that doesn't make me a rocket scientist.
@marajohnson8856
@marajohnson8856 2 жыл бұрын
If I let coding make me nervous, then I can’t get schwifty
@hingsing1
@hingsing1 4 ай бұрын
great video! easy to understand bro
@winstonsblues
@winstonsblues 3 ай бұрын
Great breakdown, thanks bro.
@jhoonyschorles7396
@jhoonyschorles7396 10 ай бұрын
Best channel out there
@pantsutsama
@pantsutsama 4 ай бұрын
can you create tutorial vids like this using WinUI 2 or 3 UI frameworks?
@yavuzmarifet4528
@yavuzmarifet4528 Жыл бұрын
clear and smooth af, thank you
@BantuBeya
@BantuBeya 6 ай бұрын
bladah bang bro yeyeyeyye!
@peternydahl6150
@peternydahl6150 2 жыл бұрын
Simply great! Thanks a lot!
@katawaya8101
@katawaya8101 Жыл бұрын
Thanks for the tutorial, but is there a faster/more intuitive way to define an object with all of its properties? It seems like defining many objects with many different properties would be very time consuming. I'm more familiar with Python, where it's as easy as calling the class with all of the desired values for the properties.
@katawaya8101
@katawaya8101 Жыл бұрын
Nevermind! The answer is in the next video: kzbin.info/www/bejne/mXLLmWmmjtB7hrM
@alexlungu7777
@alexlungu7777 3 жыл бұрын
Thank's for tutorials.
@LucParent905
@LucParent905 3 жыл бұрын
Great explanation, thanks again Bro
@CityRainee
@CityRainee 5 ай бұрын
Love you bro, youre the best
@kenlee1159
@kenlee1159 2 жыл бұрын
THANKS FOR THE KNOWLEDGE BRO
@spartanranger
@spartanranger 3 жыл бұрын
Thanks for the video Bro.
@izzok.5850
@izzok.5850 28 күн бұрын
you're the best Bro!
@VipulChandrakapure
@VipulChandrakapure 2 ай бұрын
random comment 😂😂 tbh love your videos
@krisve
@krisve Жыл бұрын
YOU ARE JUST WOWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
@f5patch634
@f5patch634 11 ай бұрын
very useful!
@the_dude_josh
@the_dude_josh 9 ай бұрын
Normally I put a random comment down below but why is it considered insecure to make them public? what would be the preferred solution?
@DonnyGGTV
@DonnyGGTV 8 ай бұрын
Im assuming having a second page for classes, and you can make them public on that page and just call them in to where you are woeking.
@Fork0
@Fork0 8 ай бұрын
Maybe a bit late to reply. In this case it doesn't matter, but usually fields should never be set to public, because they could be modified from anywhere in the program without the possibility for a validation of the newly assigned value. Take age for example: if you set it to public, anyone can just set it to whatever... 20, 60, 0, -123456. And then if your application relies on the value of age, it will have terrible consequences for the logic. Where as if you make the age private and also make 2 methods - void SetAge(int age) and int GetAge(), you can then add all the validation you want inside the SetAge method and throw exceptions if someone tries to add ages that make no sense, and use GetAge to actually get the value. Later on in this series you will learn more about this, but this is called Encapsulation (basically protection of data) and in C# you don't even need to do it with methods, but you'll learn to do it with properties (which pretty much mimic/replace those two methods i mentioned above). And as an additional info - fields are usually used for the internal logic of classes, whereas properties are exposed with public to the rest of the application so that people can use them instead of the fields.
@somyaranjanpatra4330
@somyaranjanpatra4330 3 жыл бұрын
👍🏻👍🏻👍🏻👍🏻👍🏻💯💯💯💯😍😍😍
@noodleboi5053
@noodleboi5053 2 жыл бұрын
actual gigachad coder
@christophbruns8127
@christophbruns8127 2 жыл бұрын
Großartig!!
@wnyangani263
@wnyangani263 2 жыл бұрын
thank you so much for this
@TheMontemayor
@TheMontemayor 11 ай бұрын
nice!
@kyleengelbrecht4056
@kyleengelbrecht4056 Жыл бұрын
Nooooice
@EnglishVocabularyBooster
@EnglishVocabularyBooster Жыл бұрын
Wow!
@BaySelvi
@BaySelvi Ай бұрын
Thanks.
@azolirai
@azolirai 2 жыл бұрын
Thanks man!
@Ben-fn6wp
@Ben-fn6wp Жыл бұрын
Thank you Bro!!!
@s28177
@s28177 2 жыл бұрын
Thank you
@edinbascausevic420
@edinbascausevic420 Жыл бұрын
I promote you to Dude! Thanks! Dude!!!🤣😂🤣😂
@jdot6584
@jdot6584 3 жыл бұрын
Can you do a tutorial in C?
@Sully1464
@Sully1464 16 күн бұрын
the Goat
@joniviljami5833
@joniviljami5833 8 ай бұрын
thanks bro
3 жыл бұрын
Thanks Bro!
@ahmedhassan5783
@ahmedhassan5783 10 ай бұрын
done
3 жыл бұрын
Thank Bro!
@moneyonnet4848
@moneyonnet4848 10 ай бұрын
Bro code awesome
@yashwantchoure
@yashwantchoure Жыл бұрын
"Wubba Lubba dub dub"
@cleanlens
@cleanlens 7 ай бұрын
w
@jesperpersson-t7k
@jesperpersson-t7k Жыл бұрын
if i want ro have my veriables private what do i do then?
@budderrar5751
@budderrar5751 Жыл бұрын
noice
@giuliafontana891
@giuliafontana891 Жыл бұрын
Random comment = new Random(10,12); Here it is your random comment. Thank you for simplifying concepts and making everything way easier!
@letitflow898
@letitflow898 Жыл бұрын
wubba lubba dubba
@FarhanAli-zb4iv
@FarhanAli-zb4iv 2 жыл бұрын
👍
@MoreBilaINoFilter
@MoreBilaINoFilter 7 ай бұрын
wubba lubba dub dub
@11anonymous6
@11anonymous6 Жыл бұрын
Aww, geez
@Proviper666
@Proviper666 2 жыл бұрын
System this is a random coment to help Brintey Stasy
@DySprsium
@DySprsium 26 күн бұрын
wubba lubba dub dub!!! 85th here
@thibeaultdemulder8422
@thibeaultdemulder8422 Жыл бұрын
interaction
@Kozpont
@Kozpont 7 ай бұрын
Wubba Lubba Dub Dub!!!
@definitelynotchris4776
@definitelynotchris4776 10 күн бұрын
suup
@whitedinamo
@whitedinamo 2 жыл бұрын
lesson check😇
@thatsaquib
@thatsaquib Жыл бұрын
🗿
@iamkingmatt2260
@iamkingmatt2260 6 ай бұрын
Watching in 2024
@БулатПочанов
@БулатПочанов Жыл бұрын
random comment down below
@mornebosch429
@mornebosch429 2 ай бұрын
Random comment
@axlecode8598
@axlecode8598 2 жыл бұрын
357
@theelisan30
@theelisan30 7 ай бұрын
random comment
@nikodemsomczynski
@nikodemsomczynski Жыл бұрын
random
@garshafatemianaraki9041
@garshafatemianaraki9041 26 күн бұрын
Ln
@maximmasare7966
@maximmasare7966 8 ай бұрын
Thanks bro helped a lot. 🫡
@vortex5574
@vortex5574 2 жыл бұрын
Console.WriteLine("Random comment");
@buhletshabalala5303
@buhletshabalala5303 9 күн бұрын
wubba lubba dub dub!
@alexiscoe1040
@alexiscoe1040 3 жыл бұрын
wubba lubba dub dub
@aziz-mv7qo
@aziz-mv7qo 2 жыл бұрын
u forgot the "!" at the end
@isaacchikoko8322
@isaacchikoko8322 6 ай бұрын
Wubba libba dub dub!
C# constructors 👷
5:44
Bro Code
Рет қаралды 82 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,2 МЛН
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 17 МЛН
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 27 МЛН
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,7 МЛН
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 242 М.
Python Object Oriented Programming in 10 minutes 🐍
10:04
Bro Code
Рет қаралды 400 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 844 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 919 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,7 МЛН
Java objects (OOP) ☕
10:46
Bro Code
Рет қаралды 180 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 903 М.
C# in 100 Seconds
2:27
Fireship
Рет қаралды 2,1 МЛН
C# generics ⁉️
5:33
Bro Code
Рет қаралды 76 М.
Inside Out 2: ENVY & DISGUST STOLE JOY's DRINKS!!
00:32
AnythingAlexia
Рет қаралды 17 МЛН