I am actually embarassed that I have to ask this question.
I am just learning C# and OOP and I have created a sample Windows Form
program and added a class file to it.
The class files relevant code is. . .
namespace RaceTrack
{
class Customer
{
public string Name;
public int Cash;
}
}
So now in my Form1.cs file in the Form Load event I have
Customer Greg = new Customer() { Cash = 100 };
Now under the Form Load event where I created the reference to the
object I can refer to it all day long!
Now I place a button on the form, but when I add code like
label1.Text = Greg.Cash;
I get 'Greg' does not exist in the current context
namespace RaceTrack
{
class Customer
{
public string Name;
public int Cash;
}
}
I added
using RaceTrack;
and that didn't help.
What am I doing wrong? When I try to look up scope for objects I read
that there is not really a scope for an object, it exists, until it is
garbage collected.
I am feeling super stupid about this. Can anyone help? I'll even take
the ridicule with a smile if you can help me out.