Sorry for the rookie question, as I'm just starting out with C#.
I have a class
namespace WindowsFormsApplication1
{
class people
{
public int Cash;
public string LastName;
public void GiveCash(int amount) { this.Cash = this.Cash - amount; }
public void ReceiveCash(int amount) { this.Cash = this.Cash + amount; }
}
}
and I initialize two object with it.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
people viktor = new people() { Cash = 1000, LastName = "Jushenko" };
people julia = new people() { Cash = 500, LastName = "Timoshenko" };
}
but later in the code I can not access any of those objects. For example I i use
private void button1_Click(object sender, EventArgs e)
{ viktor.cash = 200; }
it says something like "The name 'victor' does not exist in this context..." what am I doing wrong?
Thanks!
People