Hello all. I'm going to say first off that this is not a homework project.
I have a little experience writing small programs for my own personal use, although it's been a while. I have a problem that I hope some of you can shed some light on.
I'm writing a small program to parse some csv files for handicapping horse races. There are three files with a ton of information. I'm only concerned with a small amount of that data. I am attempting to arrange the data and then write that data back to a csv file that can be opened in excel.
So what I have is a Race class:
public class Race
{
public string RaceNumber { get; set; }
public string RaceDate { get; set; }
public string Track { get; set; }
public string Distance { get; set; }
public string Surface { get; set; }
public List<Horse> Horses = new List<Horse>;
}
and the horse class:
public class Horse
{
public string HorseName { get; set; }
public string raceNumber { get; set; }
public string HorseNumber { get; set; }
public string[] PP = new string[10];
}
I also have a list called raceList that contains all of the race classes.
I can loop through this and see that the data is correct. However, when I attempt to check the list of Horses inside the race class, I encounter a problem. I'm sure it has something to do with the way that I've set this up.
So I have a list<class> Race that contains a list<classs> Horses. I tried to loop through them in this manner:
foreach (Race race in raceList)
{
Debug.WriteLine(race.Track);
Debug.WriteLine(race.RaceDate);
Debug.WriteLine(race.RaceNumber);
foreach (Horse horse in Horses)
{
Debug.WriteLine(horse.HorseNumber);
Debug.WriteLine(horse.HorseName);
}
}
Right now I am currently using the debug writeline to check the data to make sure its in the proper place, but I'm getting "the name Horses does not exist in the current context.It properly loops through the raceList. I'm stumped. I tried googling (It's been a while since I've done this so I've been googling a bunch), but I haven't found anything.
If anyone has any ideas, I'd much appreciate it.
Thanks for taking the time to read.
What I have tried:
I've been googling this to no avail. I simply have no idea.