After opening the file, loop through each line, storing the player's data in a struct:
Code:
struct Player
{
public string Number;
public string Name;
public int Score;
}
Then as you read in each line of the file, store the data in a new instance of the struct:
Code:
List<Player> players = new List<Player>();
while((linein = myfile.ReadLine()) != null)
{
Player player = new Player();
string[] parts = linein.Split(',');
player.Number = parts[0];
player.Name = parts[1];
player.Score = int.Parse(parts[2]);
players.Add(player);
}
Then you can prompt the user for a name to search for and look it up in the players list:
Code:
Player foundPlayer = players.FirstOrDefault(p => p.Name == target);
if(foundPlayer != null)
{
// Print out the player stats
}