Hello!
I've used list<> for a while, but now I've stumbled upon a problem where I'm blind. For some reason I can't get this to work. I've created a class, Players, and I want to add players to a list. The list is supposed to hold football players, thus it contains name, shirtnumber, date of birth etc.
But after I've entered the players to the list, I can't show the list, here's the code:
The class:
CODE
public class Players
{
string name;
string position;
string motherclub;
string nationality;
int birthyear;
int number;
public Players(string name, string position, string motherclub, string nationality, int birthyear, int number)
{
this.name = name;
this.position = position;
this.motherclub = motherclub;
this.nationality = nationality;
this.birthyear = birthyear;
this.number = number;
}
}
The list:
CODE
class Program
{
public static void Main(string[] args)
{
List<Players> play = new List<Players>();
play.Add(new Players("Dusan Melichárek", "Mĺlvakt", "FC TIC", "Tjeckien", 1983, 40));
play.ForEach(delegate(Players S)
{
Console.WriteLine("{0}, {1}", //<--HERE! When I type S, I can't find anything!
}
Now, when I use the list.ForEach method, I can't select the parts of the list that I wan't to output (like S.name or S.position). I can't understand why, but I bet it's something simple and stupid
Can anyone see what I've done wrong?