G
grif
Hi everyone!
Been a few weeks since i've asked a noob question
At the moment I'm writing my First Form application compared to the few
console bits and pieces that ive been working on. And due to me reading a
few new books etc i've started cleaning up my code and sticking the engine
part into its own class and methods to tidy it up.
The thing i'm struggling with (due to my lack of understanding) is the scope
of variables. I understand that the block of code which they are declared in
are determines their scope etc but the trouble i'm having is carrying them
accross to the main form etc. So for example:
If I have the main form code with a click event say Form1.cs
Which has something like:
staticclass.Counter();
richtextbox1.Text = lineCount;
Basically calling the counter function from the class and the coutner
function counts the lines in a textfile etc where the variable lineCount is
declared....how do I carry that back to the main form so that I can insert
it into a textbox etc.
Obviously at the moment its giving me a not decalred scope error....i'm
guessing that It has to do with the arguments of the method in the
class....but what do i need to do to persist the variable etc???
Sorry for the newb questions...im still learning
Cheers
steve
Been a few weeks since i've asked a noob question
At the moment I'm writing my First Form application compared to the few
console bits and pieces that ive been working on. And due to me reading a
few new books etc i've started cleaning up my code and sticking the engine
part into its own class and methods to tidy it up.
The thing i'm struggling with (due to my lack of understanding) is the scope
of variables. I understand that the block of code which they are declared in
are determines their scope etc but the trouble i'm having is carrying them
accross to the main form etc. So for example:
If I have the main form code with a click event say Form1.cs
Which has something like:
staticclass.Counter();
richtextbox1.Text = lineCount;
Basically calling the counter function from the class and the coutner
function counts the lines in a textfile etc where the variable lineCount is
declared....how do I carry that back to the main form so that I can insert
it into a textbox etc.
Obviously at the moment its giving me a not decalred scope error....i'm
guessing that It has to do with the arguments of the method in the
class....but what do i need to do to persist the variable etc???
Sorry for the newb questions...im still learning
Cheers
steve