C# List of objects 🦸‍♂️

preview_player
Показать описание
C# list of objects tutorial example explained

#C# #list #objects
Рекомендации по теме
Комментарии
Автор

using System;
using System.Collections.Generic;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
List<Player> players = new List<Player>();

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

BroCodez
Автор

"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

huseyncfrov
Автор

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

teamcheese
Автор

This is gold, saved me a hell of stress

ballisticmind
Автор

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?

ci-chol
Автор

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

richardtaveras
Автор

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

SweetPeachannel
Автор

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

wzfoegq