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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Finding Files 6
Nullable class 2
for loop 3
file [?] 2
Use of event handling 6
Unable to use HTTP Channel 3
array as out parameter 5
interoperation using COM from .NET with OptionalParameter 7

Back
Top