C# objects 🧍‍♂️

Ғылым және технология

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

Пікірлер: 80

  • @BroCodez
    @BroCodez3 жыл бұрын

    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

    2 ай бұрын

    Radical!

  • @hingsing1

    @hingsing1

    Ай бұрын

    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

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

  • @aziz-mv7qo
    @aziz-mv7qo2 жыл бұрын

    wubba lubba dub dub!

  • @PixelPickleWaffle

    @PixelPickleWaffle

    Ай бұрын

    Jhinga lala hoo hoo

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

  • @andrehufschmid
    @andrehufschmid Жыл бұрын

    Perfect. Very well explained with a good example.

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

    3 ай бұрын

    I couldn't agree more

  • @victorh.lopezchavez4229
    @victorh.lopezchavez4229 Жыл бұрын

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

  • @itsashhuby6781
    @itsashhuby6781 Жыл бұрын

    You explained this so well thank you!

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

  • @peternydahl6150
    @peternydahl61502 жыл бұрын

    Simply great! Thanks a lot!

  • @yavuzmarifet4528
    @yavuzmarifet4528 Жыл бұрын

    clear and smooth af, thank you

  • @winstonsblues
    @winstonsblues19 күн бұрын

    Great breakdown, thanks bro.

  • @orpheuscreativeco9236
    @orpheuscreativeco92364 ай бұрын

    Very straightforward and relatable 👍

  • @LucParent905
    @LucParent9052 жыл бұрын

    Great explanation, thanks again Bro

  • @alexlungu7777
    @alexlungu77773 жыл бұрын

    Thank's for tutorials.

  • @CityRainee
    @CityRainee2 ай бұрын

    Love you bro, youre the best

  • @kenlee1159
    @kenlee11592 жыл бұрын

    THANKS FOR THE KNOWLEDGE BRO

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

  • @hingsing1
    @hingsing1Ай бұрын

    great video! easy to understand bro

  • @spartanranger
    @spartanranger2 жыл бұрын

    Thanks for the video Bro.

  • @wnyangani263
    @wnyangani2632 жыл бұрын

    thank you so much for this

  • @christophbruns8127
    @christophbruns81272 жыл бұрын

    Großartig!!

  • @jhoonyschorles7396
    @jhoonyschorles73967 ай бұрын

    Best channel out there

  • @azolirai
    @azolirai2 жыл бұрын

    Thanks man!

  • @TheMontemayor
    @TheMontemayor8 ай бұрын

    nice!

  • @EnglishVocabularyBooster
    @EnglishVocabularyBooster11 ай бұрын

    Wow!

  • 3 жыл бұрын

    Thanks Bro!

  • 3 жыл бұрын

    Thank Bro!

  • @BantuBeya
    @BantuBeya3 ай бұрын

    bladah bang bro yeyeyeyye!

  • @f5patch634
    @f5patch6348 ай бұрын

    very useful!

  • @joniviljami5833
    @joniviljami58335 ай бұрын

    thanks bro

  • @Ben-fn6wp
    @Ben-fn6wp Жыл бұрын

    Thank you Bro!!!

  • @s28177
    @s281772 жыл бұрын

    Thank you

  • @kyleengelbrecht4056
    @kyleengelbrecht4056 Жыл бұрын

    Nooooice

  • @budderrar5751
    @budderrar5751 Жыл бұрын

    noice

  • @moneyonnet4848
    @moneyonnet48488 ай бұрын

    Bro code awesome

  • @somyaranjanpatra4330
    @somyaranjanpatra43303 жыл бұрын

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

  • @11anonymous6
    @11anonymous6 Жыл бұрын

    Aww, geez

  • @FarhanAli-zb4iv
    @FarhanAli-zb4iv Жыл бұрын

    👍

  • @noodleboi5053
    @noodleboi5053 Жыл бұрын

    actual gigachad coder

  • @marajohnson8856
    @marajohnson88562 жыл бұрын

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

  • @krisve
    @krisve Жыл бұрын

    YOU ARE JUST WOWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

  • @isaacchikoko8322
    @isaacchikoko83223 ай бұрын

    Wubba libba dub dub!

  • @yashwantchoure
    @yashwantchoure Жыл бұрын

    "Wubba Lubba dub dub"

  • @cleanlens
    @cleanlens4 ай бұрын

    w

  • @alexandregb566
    @alexandregb56610 ай бұрын

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

  • @ahmedhassan5783
    @ahmedhassan57837 ай бұрын

    done

  • @jdot6584
    @jdot65843 жыл бұрын

    Can you do a tutorial in C?

  • @katawaya8101
    @katawaya810111 ай бұрын

    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

    11 ай бұрын

    Nevermind! The answer is in the next video: kzread.info/dash/bejne/lXWcypipic6ugLQ.html

  • @pantsutsama
    @pantsutsamaАй бұрын

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

  • @MoreBilaINoFilter
    @MoreBilaINoFilter4 ай бұрын

    wubba lubba dub dub

  • @edinbascausevic420
    @edinbascausevic42010 ай бұрын

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

  • @thatsaquib
    @thatsaquib Жыл бұрын

    🗿

  • @letitflow898
    @letitflow89810 ай бұрын

    wubba lubba dubba

  • @Kozpont
    @Kozpont4 ай бұрын

    Wubba Lubba Dub Dub!!!

  • @thibeaultdemulder8422
    @thibeaultdemulder8422 Жыл бұрын

    interaction

  • @user-us3kg2jy5z
    @user-us3kg2jy5z Жыл бұрын

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

  • @Proviper666
    @Proviper666 Жыл бұрын

    System this is a random coment to help Brintey Stasy

  • @the_dude_josh
    @the_dude_josh6 ай бұрын

    Normally I put a random comment down below but why is it considered insecure to make them public? what would be the preferred solution?

  • @Donny956

    @Donny956

    6 ай бұрын

    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

    5 ай бұрын

    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.

  • @axlecode8598
    @axlecode8598 Жыл бұрын

    357

  • @whitedinamo
    @whitedinamo2 жыл бұрын

    lesson check😇

  • @iamkingmatt2260
    @iamkingmatt22603 ай бұрын

    Watching in 2024

  • @nikodemsomczynski
    @nikodemsomczynski Жыл бұрын

    random

  • @theelisan30
    @theelisan304 ай бұрын

    random comment

  • @user-up7kv5si4x
    @user-up7kv5si4x11 ай бұрын

    random comment down below

  • @giuliafontana891
    @giuliafontana891 Жыл бұрын

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

  • @maximmasare7966
    @maximmasare79665 ай бұрын

    Thanks bro helped a lot. 🫡

  • @vortex5574
    @vortex55742 жыл бұрын

    Console.WriteLine("Random comment");

  • @alexiscoe1040
    @alexiscoe10403 жыл бұрын

    wubba lubba dub dub

  • @aziz-mv7qo

    @aziz-mv7qo

    2 жыл бұрын

    u forgot the "!" at the end

Келесі