The textfile I'm reading from has numbers in it.
The return is System32 Int[]
and not the numbers I want to see. What am I doing wrong?
static void Main(string[] args)
{
StreamReader fromFile = new StreamReader("test.txt");
int[] numbers = gatherNumbers(fromFile);
Console.WriteLine("Files from test.txt has been gathered...");
string textFile = userInput("Enter the filename that you wish to store the result in: ");
StreamWriter tillFil = new StreamWriter(textFile);
tillFil.WriteLine("Summa " + numbers);
Console.WriteLine("Summa " + numbers);
tillFil.Close();
Console.ReadLine();
}
private static int[] gatherNumbers(StreamReader fromFile)
{
List<int> listan = new List<int>();
string rad = fromFile.ReadLine();
while (rad != null)
{
int tal = Convert.ToInt32(rad);
listan.Add(tal);
rad = fromFile.ReadLine();
}
return listan.ToArray();
}
private static string userInput(string nameOfTextFile)
{
Console.WriteLine(nameOfTextFile);
string answer = Console.ReadLine();
return answer;
}