C# List of objects 🦸‍♂️

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • C# list of objects tutorial example explained
    #C# #list #objects

ความคิดเห็น • 31

  • @BroCodez
    @BroCodez  3 ปีที่แล้ว +22

    using System;
    using System.Collections.Generic;
    namespace MyFirstProgram
    {
    class Program
    {
    static void Main(string[] args)
    {
    List players = new List();
    players.Add(new Player("Chad"));
    players.Add(new Player("Steve"));
    players.Add(new Player("Karen"));
    foreach (Player player in players)
    {
    Console.WriteLine(player);
    }
    Console.ReadKey();
    }
    }
    class Player
    {
    public String username;
    public Player(String username)
    {
    this.username = username;
    }
    public override string ToString()
    {
    return username;
    }
    }
    }

    • @DiogoGaming2
      @DiogoGaming2 ปีที่แล้ว

      how can i do that inside a method?
      So i want a function to use user input in the console to create a object

    • @alikgnmnkse6507
      @alikgnmnkse6507 ปีที่แล้ว

      @@DiogoGaming2 Just use Convert.ToString() method and create another function in order to take input for instance:
      using System;
      using System.Collections.Generic;
      namespace MyFirstProgram
      {
      class Program
      {
      static void Main(string[] args)
      {
      Player player = new Player("Ali");
      player.ChangeName();
      }
      class Player
      {
      public String name;
      public String new_name;
      public Player(String name)
      {
      this.name = name;
      }
      public void ChangeName()
      {
      Console.WriteLine($"What would you like the new name to be? Current name of player is: {name}");
      String new_name = Convert.ToString(Console.ReadLine());
      name = new_name;
      Console.WriteLine($"Name of player has been changed new name is: {new_name}");
      }
      }
      }
      }

    • @Sam4Progress
      @Sam4Progress 7 หลายเดือนก่อน

      This right here, specifically how to properly write a foreach function, helped me more than you can possibly know!

  • @huseyncfrov2514
    @huseyncfrov2514 10 หลายเดือนก่อน +3

    "Religion, ideology, resources, land, spite, love or just because… No matter how pathetic the reason, it’s enough to start war. War will never cease to exist… reasons can be thought up after the fact… Human nature pursues strife."
    ~ Pain

  •  3 ปีที่แล้ว

    Thanks Bro!

  • @the_dude_josh
    @the_dude_josh 9 หลายเดือนก่อน

    A random comment down below.

  • @cervan1es
    @cervan1es 8 หลายเดือนก่อน

    random comment down below

  • @triton5457
    @triton5457 2 ปีที่แล้ว

    Random comment #44

  • @Proviper666
    @Proviper666 2 ปีที่แล้ว

    This is not random comment!

  • @teamcheese1045
    @teamcheese1045 2 ปีที่แล้ว +5

    fast and clear, thank you! I have been trying to find how to make a new object anonymous for so long now

  • @CầnbiếtKo-k5i
    @CầnbiếtKo-k5i ปีที่แล้ว

    helo , tôi muốn ông làm về khoá học unity được không , nếu không chả lời thì chỉ có người chếết mới làm vậy

  • @ci-chol
    @ci-chol 2 ปีที่แล้ว +2

    How would you go about sorting or searching this list of objects? Since the anonymous objects are all the same according to the list (duplicate Player objects), how could I sort and perform a binary search to find a user with a specific name?

    • @beterc0re20
      @beterc0re20 2 หลายเดือนก่อน

      LINQ

  • @Suckit-b6k
    @Suckit-b6k 10 หลายเดือนก่อน

    christmas

  • @richardtaveras7028
    @richardtaveras7028 9 หลายเดือนก่อน

    Can you explain why overriding the ToString method changes the display of the object when passing it through writeline

  • @SweetPeachannel
    @SweetPeachannel ปีที่แล้ว

    where is the video like this but remove and clear instead add pls?

  • @spartanranger
    @spartanranger 3 ปีที่แล้ว +1

    Thanks for the video Bro.

  • @syawo7062
    @syawo7062 2 ปีที่แล้ว

    holy shit I fucking love you

  • @wombozombo
    @wombozombo ปีที่แล้ว

    random comment

  • @benedictcherlet8583
    @benedictcherlet8583 11 หลายเดือนก่อน

    Random Comment

  • @FullExtension1
    @FullExtension1 ปีที่แล้ว

    you are such a bro, bro.

  • @nadeekathusharidayananda4094
    @nadeekathusharidayananda4094 3 ปีที่แล้ว

    Cloud app in java 😭😭😭

  • @ballisticmind
    @ballisticmind ปีที่แล้ว

    This is gold, saved me a hell of stress

  • @whitedinamo
    @whitedinamo 2 ปีที่แล้ว

    lesson check😇

  • @tdkom
    @tdkom 2 ปีที่แล้ว

    thx man really helping me out here

  • @Warpgatez
    @Warpgatez ปีที่แล้ว

    Very nice.

  • @TheCodeHunter
    @TheCodeHunter 3 ปีที่แล้ว

    nice :D

  • @__foo__
    @__foo__ ปีที่แล้ว

    Worked!

  • @aditya_asundi
    @aditya_asundi 3 ปีที่แล้ว

    third