我已经尝试了一个小时来解决这个问题,并尝试解析但没有奏效。下面的代码在我转换联赛数据 [2] 和联赛数据 [3] 的两行上不断给我错误输入字符串格式不正确。我错过了一些简单的东西吗?
public static void readLeagues(string theFile, ArrayList allLeagues)
{
StreamReader inLeagues = null;
bool anyMoreLeagues = false;
string[] leagueData = new string[frmLeagues.numLeagueItems];
string[] fixtureData = new string[frmLeagues.numFixItems];
Leagues tempLeague;
Fixtures tempFix;
int numFixInLeague, leaguePrize;
if (fileOpenForReadOK(theFile, ref inLeagues))
{
anyMoreLeagues = getNext(frmLeagues.numLeagueItems, inLeagues, leagueData);
while (anyMoreLeagues == true)
{
leaguePrize = Convert.ToInt32(leagueData[2]);
numFixInLeague = Convert.ToInt32(leagueData[3]);
tempLeague = new Leagues(leagueData[0], leagueData[1],numFixInLeague,
leaguePrize);
for (int i = 0; i < numFixInLeague; i++)
{
getNext(frmLeagues.numFixItems, inLeagues, fixtureData);
tempFix = new Fixtures(fixtureData[0], fixtureData[1], fixtureData[2]
, fixtureData[3], fixtureData[4]);
tempLeague.addFixturesToLeague(tempLeague.getLeagueFixtures(),tempFix);
}
allLeagues.Add(tempLeague);
anyMoreLeagues = getNext(frmLeagues.numLeagueItems, inLeagues, leagueData);
}
}
if (inLeagues != null) inLeagues.Close();
以下是联盟课程的代码谢谢,杰克
类联赛 { 私人字符串 LeagueName; 私人字符串 LeagueSponsor;私人 int LeaguePrize; 私人 int LeagueNumFixtures; ArrayList LeagueFixtures;
public Leagues(string inLeagueName, string inLeagueSponsor, int inLeaguePrize,
int inLeagueNumFixtures)
{
LeagueName = inLeagueName;
LeagueSponsor = inLeagueSponsor;
LeaguePrize = inLeaguePrize;
LeagueNumFixtures = inLeagueNumFixtures;
LeagueFixtures = new ArrayList();
}
public ArrayList addFixturesToLeague(ArrayList fixturesSoFar, Fixtures theNewFixture)
{
fixturesSoFar.Add(theNewFixture);
LeagueNumFixtures = fixturesSoFar.Count;
return fixturesSoFar;
}
public void setLeagueName(string inLeagueName)
{
LeagueName = inLeagueName;
}
public void setLeagueSponsor(string inLeagueSponsor)
{
LeagueSponsor = inLeagueSponsor;
}
public void setLeaguePrize(int inLeaguePrize)
{
LeaguePrize = inLeaguePrize;
}
public void setLeagueNumofFixture(int inLeagueNumFixtures)
{
LeagueNumFixtures = inLeagueNumFixtures;
}
public void setLeagueFixtures(ArrayList inLeagueFix)
{
LeagueFixtures = inLeagueFix;
}
public string getLeagueName()
{
return LeagueName;
}
public string getLeagueSponsor()
{
return LeagueSponsor;
}
public int getLeaguePrize()
{
return LeaguePrize;
}
public int getLeagueNumFixtures()
{
return LeagueNumFixtures;
}
public ArrayList getLeagueFixtures()
{
return LeagueFixtures;
}
}
}