我正在尝试创建一个对象列表来创建一个排行榜。
这是class
为object
:
public class LeagueRow
{
public String teamName { get; set; }
public String managerName { get; set; }
public Int32 played { get; set; }
public Int32 won { get; set; }
public Int32 draw { get; set; }
public Int32 lost { get; set; }
public Int32 goalsFor { get; set; }
public Int32 goalsAgainst { get; set; }
public Int32 goalDifference { get; set; }
public Int32 points { get; set; }
}
然后我尝试添加每一行,并显示每一行literal1
以查看列表的内容。在这里看到:
goalDifference = goalsFor - goalsAgainst;
List<LeagueRow> leagueTeamRow = new List<LeagueRow>();
leagueTeamRow.Add(new LeagueRow { teamName = dReader["teamName"].ToString(), managerName = dReader["ManagerFirstName"].ToString() + " " + dReader["ManagerSurname"].ToString(), played = gamesPlayed, won = won, draw = draw, lost = lost, goalsFor = goalsFor, goalsAgainst = goalsAgainst, goalDifference = goalDifference, points = points });
for (int i = 0; i < leagueTeamRow.Count; i++)
{
Literal1.Text += (leagueTeamRow[i].ToString());
}
我遇到了一个问题,因为在rows
中显示了正确的数量literal
,但是数据只有项目的名称和行名称,例如:PROJECTNAME.LeagueRow
多次。
谁能告诉我我做错了什么?