You never actually add any values to your test array. This line of code:
double[] test = new double[numberArray.Length];
Is just saying create a blank array, of x size. The values inside that array with be the default (the default of double is 0). You need to assign values to the array if you want them to be there.
The easiest way to do convert your text file lines to a double array would be to use a little Linq:
if(File.Exists(newPath))
{
double[] test = File.ReadLines(newPath).Select(x => double.Parse(x)).ToArray()
foreach(double number in test)
{
Console.WriteLine(number);
}
Console.ReadLine();
}
The has the drawback of having no error handling though.
If you want to have error handling your code will just be a little longer, and you should create a ParseLines() method:
double[] test = ParseLines(newPath).ToArray()
foreach(double number in test)
{
Console.WriteLine(number);
}
Console.ReadLine();
private static IEnumerable<double> ParseLines(string filePath)
{
if(File.Exists(newPath))
{
foreach(string line in File.ReadLines(newPath))
{
double output;
if(double.TryParse(line, out output))
{
yield return output;
}
}
}
}
doubleis zerodoublearray though, you just create a new array with the same length