Подскажите где ошибка - C#
Формулировка задачи:
Всем привет.
Есть класс public class Footballplayer
в main создаю его экземпляр и благополучно вывожу его на консоль. но. после создаю второй класс, в конструктор которого нужно передать список из элементов первого и вывести этот список на консоль. вот тут то у меня ничего не выходит......
при выводе получаю -смотрите вложение. Очень прошу вас- подскажите что не так, как вывести этот список.
namespace FootballTeam
{
public class Footballplayer {
private string Surname { set; get; }
private string Name { set; get; }
private int DateOfBirth { set; get; }
private string PlayerStatus { set; get; }
private string StateOfHealth { set; get; }
private int MonthlySalary { set; get; }
public Footballplayer(string asurname, string aname, int adateOfBirth, string aplayerStatus,
string astateOfHealth,
int amonthlySalary)
{
Surname = asurname;
Name = aname;
DateOfBirth = adateOfBirth;
PlayerStatus = aplayerStatus;
StateOfHealth = astateOfHealth;
MonthlySalary = amonthlySalary;
}
public void InfoDisplay()
{
Console.WriteLine(Surname + " " + Name + " " + DateOfBirth + " " + PlayerStatus + " " + StateOfHealth + " " +
MonthlySalary);
}
}
}namespace FootballTeam
{
internal class FootballTeam
{
public List<Footballplayer> Footballplayerlist = new List<Footballplayer>();
public void AddFootballplayer(Footballplayer newfootballplayer)
{
Footballplayerlist.Add(newfootballplayer);
}
public void InfoDisplay()
{
foreach (Footballplayer footballplayer in Footballplayerlist)
{
Console.WriteLine(footballplayer);
}
}
}
}
namespace FootballTeam
{
class Program
{
static void Main(string[] args)
{
Footballplayer g=new Footballplayer("Nesmachniy ","Andrey ",1975 ,"zashitnik ","healthy ",30000);
g.InfoDisplay();
Footballplayer h = new Footballplayer("Goran ", "Goranchich ", 1975, "zashitnik ", "healthy ", 30000);
h.InfoDisplay();
FootballTeam dinamo=new FootballTeam();
dinamo.AddFootballplayer(g);
dinamo.AddFootballplayer(h);
dinamo.InfoDisplay();
}
}
}Решение задачи: «Подскажите где ошибка»
textual
Листинг программы
public void InfoDisplay()
{
foreach (Footballplayer footballplayer in Footballplayerlist)
{
footballplayer.InfoDisplay();
}
}