I have read in a file, sorted the file by into three columns and put all of the data in each columns into 3 arrays. I now need to make a method to get the max value out of the second column array. This is the code:
static void Main(string[] args)
{
string file1 = System.IO.File.ReadAllText(@"C:\file1.txt");
List<double> Array1 = new List<double>();
List<double> Array2 = new List<double>();
List<double> Array3 = new List<double>();
IEnumerable<string> lines = File.ReadLines(@"C:\File1.txt");
foreach (string line in lines)
{
string[] columns = line.Split(',');
if (columns.Length != 3)
{
continue; // skips this line
}
Array1.Add(Convert.ToDouble(columns[0]));
Array2.Add(Convert.ToDouble(columns[1]));
Array3.Add(Convert.ToDouble(columns[2]));
}
Console.WriteLine(Max(Array1.ToArray()));
}
static double Max (double[] x)
{
double maxValue = x.Max();
return maxValue;
}
ERROR: Type or namespace definition, or end-of-file expected.
I need to fix the Max Method and also I do not know how to Say that it is Array 2 that we need to get the max value of. I then need to go back up to the main and Use the Max Method to get the maximum value of array 2. Clearly their are beginners errors in the Max function but I have researched the problem andI am unsure of how to proceed.