I need to read in an array of baseball player names and various stats that is delimited with a ';'. Here are 2 lines so my example code will make sense
Abreu, J;CWS;1B;30;101;0.29
Altuve, J;HOU;2B;15;66;0.313
Currently I am reading the file into an array where each line is in its own index in the array with the following code:
public static void fillArray()
{
string[] linesInFile = File.ReadAllLines(GlobalVariables.filePath);
//EACH LINE IS A STRING AT THIS POINT
foreach (string s in linesInFile)
{
string[] items = s.Split(';');
for (int i = 0; i < items.Length; i++)
{
Console.WriteLine(items[i]);
//Console.WriteLine(items[1]);
}
}
}
The only issue is I'm new to C# and don't know how to access this filled array from a different method so I can sort it and display various info etc.
I've searched all permutations I can think of on google, but I can't find any relevant answers.
Thanks for the help.
