I am very new to c# and Im having issues trying to understanding this. How to pass a parameter to (or from I tend to confuse the terminology) the main function in order to read a text file? I have a python function that better shows what I want to do.
def readFile(filename):
data = []
source = file(filename)
for line in source:
words = line.split()
for word in words:
data.append(int(word))
source.close()
return data
I have a basic understanding of how to open files in c# but scouring the web I can't find anything that can help me do what I want or at least help translate. here's my basic understanding:
using System;
using System.Text;
using System.IO;
public class Readingfiles {
public static void Main()
{
StreamReader src = new StreamReader("Data.txt");
while(!src.EndOfStream)
{
string line = src.ReadLine();
Console.WriteLine(line);
}
}
}
Please help, If it helps, Im using sublime text and compiling on terminal through mcs/mono.