How to code this, want to use 2 separate classes

  • Thread starter Thread starter Reinier Beeckman
  • Start date Start date
R

Reinier Beeckman

Hi,

I have a program which opens a textfile. Now i have this code in the main void like this

public static void Main(string[] args)
{
StreamReader s = File.OpenText(".\\textfile.txt");
string read = null;
while ((read = s.ReadLine()) != null)
{
contentOfTextArray.Add(read);
}
s.Close();
}

what i would like to have is that i put the reading text code inside another module and call this method from main but i just can't seem to make it work, when i return the array it doesn't work. How can i set it up so that i have 2 separate classes ?

Thanks in advance for any reactions !
 
[If you could set your newsreader to wrap lines at 80 columns, it would
be easier to reply.]

Reinier Beeckman said:
I have a program which opens a textfile. Now i have this code in the
main void like this

public static void Main(string[] args)
{
StreamReader s = File.OpenText(".\\textfile.txt");
string read = null;
while ((read = s.ReadLine()) != null)
{
contentOfTextArray.Add(read);
}
s.Close();
}

what i would like to have is that i put the reading text code inside
another module and call this method from main but i just can't seem to
make it work, when i return the array it doesn't work. How can i set
it up so that i have 2 separate classes ?

Please post the code that's failing - it should be fine.
 
Back
Top