[SOLVED] The name xyz does not exist in the current context. I know why it happens but can't fix.
I have a simple form with a textbox.
When the user hits '1' the textbox should display '1'.
But let's look inside the program:
Normally, I could do something like: setText("1");
But since I'm trying to incorporate OOP principles, I should be doing something more like: ghostClass.setText("1");
setText() basically does this -> theTextBox.Text = textToSet;
Yes, without OOP, that'd work. But with OOP, the ghostClass shouldn't
even know theTextBox exists right? So it can't do this ->
theTextBox.Text = textToSet; <- because this -> The name
'theTextBox' does not exist in the current context. <- would happen.
I was thinking that instead of -> setText("1") <- I should be
using somethign clsoer to -> theTextBox.Text =
ghostClass.setText("1"); <- but when I look at that I feel it should
just say -> theTextBox.Text = "1"; <- and that I have unnecssary
complicated the code--I mean why would I sent the text to set only to
have it returned? -_-
I could eleborate on the issue even more by introducing another method
-> ghostClass.clearTextBox(); As before I can't use ->
theTextBox.Text = string.Empty <- because of the existence issue.
Please help.