C# objects 🧍‍♂️

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • 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");
    }
    }
    }

КОМЕНТАРІ • 93

  • @BroCodez
    @BroCodez  3 роки тому +20

    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

  • @ino1023
    @ino1023 Рік тому +14

    Omg you're awesome! I struggled with OOP for 2 weeks in class and you just made this so simple. Thank you!

  • @aarongarcia3296
    @aarongarcia3296 Рік тому +12

    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

  • @stapelton21
    @stapelton21 Рік тому +4

    @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 12 днів тому

    Great video! Very easy to grasp and is easy to understand the concepts of a class. Appreciate this!

  • @victorh.lopezchavez4229
    @victorh.lopezchavez4229 Рік тому +1

    Nice video bro!! you help to understand in a good way how objects works!!

  • @rafinoor2456
    @rafinoor2456 День тому

    My teacher just send our class a 30 minutes video and your videos just saved me 20 minutes. Well deserved for a new subscriber

  • @andrehufschmid
    @andrehufschmid Рік тому +1

    Perfect. Very well explained with a good example.

  • @liamspruyt
    @liamspruyt 8 днів тому

    simple but effective teaching!

  • @willlywillly
    @willlywillly Рік тому +1

    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.

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

  • @itsashhuby6781
    @itsashhuby6781 Рік тому +1

    You explained this so well thank you!

  • @orpheuscreativeco9236
    @orpheuscreativeco9236 7 місяців тому

    Very straightforward and relatable 👍

  • @aziz-mv7qo
    @aziz-mv7qo 3 роки тому +34

    wubba lubba dub dub!

  • @hingsing1
    @hingsing1 4 місяці тому

    great video! easy to understand bro

  • @winstonsblues
    @winstonsblues 3 місяці тому

    Great breakdown, thanks bro.

  • @pantsutsama
    @pantsutsama 4 місяці тому

    can you create tutorial vids like this using WinUI 2 or 3 UI frameworks?

  • @marajohnson8856
    @marajohnson8856 2 роки тому +1

    If I let coding make me nervous, then I can’t get schwifty

  • @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: ua-cam.com/video/cAhh6pYkHPQ/v-deo.html

  • @peternydahl6150
    @peternydahl6150 2 роки тому

    Simply great! Thanks a lot!

  • @LucParent905
    @LucParent905 3 роки тому

    Great explanation, thanks again Bro

  • @alexlungu7777
    @alexlungu7777 3 роки тому

    Thank's for tutorials.

  • @CityRainee
    @CityRainee 6 місяців тому

    Love you bro, youre the best

  • @alexandregb566
    @alexandregb566 Рік тому

    Evereyone's first project: "Hello world"
    My first project: Creating a human being from scratch

  • @yavuzmarifet4528
    @yavuzmarifet4528 Рік тому

    clear and smooth af, thank you

  • @jhoonyschorles7396
    @jhoonyschorles7396 10 місяців тому

    Best channel out there

  • @krisve
    @krisve Рік тому +1

    YOU ARE JUST WOWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

  • @spartanranger
    @spartanranger 3 роки тому

    Thanks for the video Bro.

  • @izzok.5850
    @izzok.5850 Місяць тому

    you're the best Bro!

  • @kenlee1159
    @kenlee1159 2 роки тому

    THANKS FOR THE KNOWLEDGE BRO

  • @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 9 місяців тому +1

      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.

  • @jdot6584
    @jdot6584 3 роки тому

    Can you do a tutorial in C?

  • @wnyangani263
    @wnyangani263 2 роки тому

    thank you so much for this

  • @f5patch634
    @f5patch634 11 місяців тому

    very useful!

  • @BaySelvi
    @BaySelvi Місяць тому

    Thanks.

  • @BantuBeya
    @BantuBeya 6 місяців тому

    bladah bang bro yeyeyeyye!

  • @s28177
    @s28177 2 роки тому

    Thank you

  • @Ben-fn6wp
    @Ben-fn6wp Рік тому

    Thank you Bro!!!

  •  3 роки тому

    Thanks Bro!

  • @VipulChandrakapure
    @VipulChandrakapure 2 місяці тому

    random comment 😂😂 tbh love your videos

  • @jesperpersson-t7k
    @jesperpersson-t7k Рік тому

    if i want ro have my veriables private what do i do then?

  • @joniviljami5833
    @joniviljami5833 8 місяців тому

    thanks bro

  •  3 роки тому

    Thank Bro!

  • @azolirai
    @azolirai 2 роки тому

    Thanks man!

  • @TheMontemayor
    @TheMontemayor 11 місяців тому

    nice!

  • @Sully1464
    @Sully1464 20 днів тому

    the Goat

  • @christophbruns8127
    @christophbruns8127 2 роки тому

    Großartig!!

  • @noodleboi5053
    @noodleboi5053 2 роки тому

    actual gigachad coder

  • @EnglishVocabularyBooster
    @EnglishVocabularyBooster Рік тому

    Wow!

  • @ahmedhassan5783
    @ahmedhassan5783 10 місяців тому +1

    done

  • @moneyonnet4848
    @moneyonnet4848 11 місяців тому

    Bro code awesome

  • @kyleengelbrecht4056
    @kyleengelbrecht4056 Рік тому

    Nooooice

  • @edinbascausevic420
    @edinbascausevic420 Рік тому

    I promote you to Dude! Thanks! Dude!!!🤣😂🤣😂

  • @somyaranjanpatra4330
    @somyaranjanpatra4330 3 роки тому

    👍🏻👍🏻👍🏻👍🏻👍🏻💯💯💯💯😍😍😍

  • @cleanlens
    @cleanlens 8 місяців тому +1

    w

  • @Proviper666
    @Proviper666 2 роки тому

    System this is a random coment to help Brintey Stasy

  • @FarhanAli-zb4iv
    @FarhanAli-zb4iv 2 роки тому

    👍

  • @11anonymous6
    @11anonymous6 Рік тому

    Aww, geez

  • @yashwantchoure
    @yashwantchoure Рік тому

    "Wubba Lubba dub dub"

  • @budderrar5751
    @budderrar5751 Рік тому

    noice

  • @DySprsium
    @DySprsium Місяць тому

    wubba lubba dub dub!!! 85th here

  • @letitflow898
    @letitflow898 Рік тому

    wubba lubba dubba

  • @MoreBilaINoFilter
    @MoreBilaINoFilter 7 місяців тому

    wubba lubba dub dub

  • @giuliafontana891
    @giuliafontana891 Рік тому

    Random comment = new Random(10,12);
    Here it is your random comment. Thank you for simplifying concepts and making everything way easier!

  • @thibeaultdemulder8422
    @thibeaultdemulder8422 Рік тому

    interaction

  • @Kozpont
    @Kozpont 7 місяців тому

    Wubba Lubba Dub Dub!!!

  • @whitedinamo
    @whitedinamo 2 роки тому

    lesson check😇

  • @iamkingmatt2260
    @iamkingmatt2260 6 місяців тому

    Watching in 2024

  • @thatsaquib
    @thatsaquib Рік тому

    🗿

  • @definitelynotchris4776
    @definitelynotchris4776 14 днів тому

    suup

  • @axlecode8598
    @axlecode8598 2 роки тому

    357

  • @БулатПочанов
    @БулатПочанов Рік тому

    random comment down below

  • @mornebosch429
    @mornebosch429 2 місяці тому

    Random comment

  • @ishanbasnet6811
    @ishanbasnet6811 14 годин тому

    random

  • @theelisan30
    @theelisan30 7 місяців тому

    random comment

  • @garshafatemianaraki9041
    @garshafatemianaraki9041 29 днів тому

    Ln

  • @maximmasare7966
    @maximmasare7966 8 місяців тому

    Thanks bro helped a lot. 🫡

  • @vortex5574
    @vortex5574 2 роки тому

    Console.WriteLine("Random comment");

  • @buhletshabalala5303
    @buhletshabalala5303 12 днів тому

    wubba lubba dub dub!

  • @alexiscoe1040
    @alexiscoe1040 3 роки тому +1

    wubba lubba dub dub

    • @aziz-mv7qo
      @aziz-mv7qo 3 роки тому

      u forgot the "!" at the end

  • @nikodemsomczynski
    @nikodemsomczynski Рік тому

    random

  • @isaacchikoko8322
    @isaacchikoko8322 6 місяців тому

    Wubba libba dub dub!